diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 3e9cc3a..6693213 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -2,11 +2,13 @@ name: Build and Deploy on: push: - branches: [ "master"] + branches: ["master"] # Publish semver tags as releases. tags: [ "v*.*.*" ] pull_request: - branches: [ "master"] + branches: ["master"] + release: + types: ["created"] workflow_dispatch: inputs: {} @@ -62,7 +64,22 @@ jobs: deploy: needs: [ "scan" ] runs-on: ubuntu-20.04 - if: startsWith(github.ref, 'refs/tags/v') + if: github.event_name == 'release' && github.event.action == 'created' steps: + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GHCR_TOKEN }} - uses: actions/checkout@v2 - - run: make push + with: + # Need tags for Makefile logic to work + fetch-depth: 0 + - name: Build and Push Docker Images + run: make push