From 8962b3ad7517ebd33a4799167b932dd34830146c Mon Sep 17 00:00:00 2001 From: Damien Duportal Date: Tue, 12 Mar 2024 19:28:18 +0100 Subject: [PATCH] Update build-and-deploy.yml --- .github/workflows/build-and-deploy.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 9d2e187..ae482d4 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -3,18 +3,10 @@ on: ## Events from external actor, or from code pushed (includes tags pushed) push: branches: - - main - - 'refs/tags/*' + - '*' tags: - '*' - pull_request: - ## Events from the GitHub UI (as when publishing a release) - # When a release is "released" (draft or released published, no pre-release) - https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#release - release: - types: [released] - # When a tag or branch is created in the GitHub UI - create: jobs: build: # In the future it would be good to run the tests on amd64 and arm64 @@ -40,15 +32,15 @@ jobs: run: make README #### Deployment Zone: only on main branch (or tags) - name: Login to Docker Hub for Deployment - if: startsWith('refs/tag', github.ref) || startsWith('refs/heads/main', github.ref) + if: github.ref_name == 'main' || github.ref_type == 'tag' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Deploy - if: startsWith('refs/tag', github.ref) || startsWith('refs/heads/main', github.ref) + if: github.ref_name == 'main' || github.ref_type == 'tag' run: | - export IMAGE_VERSION="$(echo ${GITHUB_REF#refs/tags/} | grep -v 'refs/heads')" + export IMAGE_VERSION="${{ github.ref_name }}" export IMAGE_NAME="asciidoctor/docker-asciidoctor" git config --local user.name "${GITHUB_ACTOR}" git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com"