aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/ci.yml
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-03-26 10:20:29 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2022-03-26 10:35:08 +0300
commitfcc525c023fab26b58377a62147f4b184bb00f59 (patch)
treee74b01eed5e5e5149a8df0f1599a4ab3715ba364 /.github/workflows/ci.yml
parentdocker: best practices (diff)
downloadvoid-fcc525c023fab26b58377a62147f4b184bb00f59.tar.gz
void-fcc525c023fab26b58377a62147f4b184bb00f59.zip
workflows/ci: deploy to Docker Hub, not to host directly
Copied the relevant workflow bits from my cgitize repo.
Diffstat (limited to '')
-rw-r--r--.github/workflows/ci.yml42
1 files changed, 25 insertions, 17 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 947238a..4b07403 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -22,24 +22,32 @@ jobs:
- name: Run tests
run: make test
- deploy:
+ publish_docker:
needs: [test]
runs-on: ubuntu-latest
- name: Deploy
- if: github.ref == 'refs/heads/master'
- env:
- DOCKER_HOST: 'tcp://${{ secrets.DEPLOY_DOCKER_HOST }}:${{ secrets.DEPLOY_DOCKER_PORT }}'
+ name: 'Publish: Docker Hub'
+ if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
steps:
- - name: Checkout
- uses: actions/checkout@v2
- - name: Set up VPN
- uses: egor-tensin/setup-wireguard@v1
+ - id: meta
+ name: Docker Hub metadata
+ uses: docker/metadata-action@v3
+ with:
+ images: '${{ secrets.DOCKERHUB_USERNAME }}/void'
+ flavor: |
+ latest=auto
+ tags: |
+ type=ref,event=branch
+ type=semver,pattern={{version}}
+ type=semver,pattern={{major}}.{{minor}}
+ type=semver,pattern={{major}}
+ - name: Login to Docker Hub
+ uses: docker/login-action@v1
+ with:
+ username: '${{ secrets.DOCKERHUB_USERNAME }}'
+ password: '${{ secrets.DOCKERHUB_TOKEN }}'
+ - name: Build and publish
+ uses: docker/build-push-action@v2
with:
- endpoint: '${{ secrets.WG_ENDPOINT }}'
- endpoint_public_key: '${{ secrets.WG_ENDPOINT_PUBLIC_KEY }}'
- ips: '${{ secrets.WG_IPS }}'
- allowed_ips: '${{ secrets.WG_ALLOWED_IPS }}'
- private_key: '${{ secrets.WG_PRIVATE_KEY }}'
- preshared_key: '${{ secrets.WG_PRESHARED_KEY }}'
- - name: Deploy
- run: make deploy
+ push: true
+ tags: '${{ steps.meta.outputs.tags }}'
+ labels: '${{ steps.meta.outputs.labels }}'