From fcc525c023fab26b58377a62147f4b184bb00f59 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 26 Mar 2022 10:20:29 +0300 Subject: workflows/ci: deploy to Docker Hub, not to host directly Copied the relevant workflow bits from my cgitize repo. --- .github/workflows/ci.yml | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to '.github/workflows') 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 }}' -- cgit v1.2.3