From c39fb5d9aae7ff52d274122cf261e4a88cf9d98d Mon Sep 17 00:00:00 2001 From: Novikov Sergey Date: Thu, 22 Dec 2022 14:31:28 +0100 Subject: [PATCH] Gha simplify (#4) * Simplify GHA * Remove REF in favor of `ref_type` --- .github/workflows/docker-build.yml | 33 ++++++++++-------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 3ef63cb..cfe6e3f 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -3,7 +3,8 @@ name: Build-Publish on: push: - branches: + branches: ["**"] + tags-ignore: ["**"] release: types: [released] @@ -31,27 +32,15 @@ jobs: # Extract python subversion PYTHON_MAJOR=$(echo $PYTHON | sed 's/\.[0-9]\+$//') PYTHON_PATCH=$(echo $PYTHON | sed 's/^[0-9]\+\.[0-9]\+\.//') - - # Extract git tag or git branch - if echo "${GITHUB_REF}" | grep -q "refs/tags/"; then - SLUG="${GITHUB_REF/refs\/tags\//}" - fi - if echo "${GITHUB_REF}" | grep -q "refs/heads/"; then - SLUG="${GITHUB_REF/refs\/heads\//}" - if echo "${SLUG}" | grep -q '^dependabot\/'; then - SLUG="${SLUG/dependabot\/github_actions\/actions\//dependabot-}" - fi - fi # Build Docker image tag - if [ "${SLUG}" = "master" ]; then - TAG="${PYTHON}" - else + if [ "${{ github.ref_type }}" = "tag" ]; then TAG="${PYTHON_MAJOR}" + else + TAG="${PYTHON}" fi # Output for debugging - echo "SLUG=${SLUG}" echo "TAG=${TAG}" # Store GitHub Action env vars @@ -122,11 +111,11 @@ jobs: # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( - (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) + (github.event_name == 'schedule' && github.ref_name == 'master') || - (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) + (github.event_name == 'push' && github.ref_name == 'master') || - (github.event_name == 'release' && github.event.action == 'released') + (github.event_name == 'release' && github.event.action == 'released') ) - name: Push @@ -149,9 +138,9 @@ jobs: # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( - (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) + (github.event_name == 'schedule' && github.ref_name == 'master') || - (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) + (github.event_name == 'push' && github.ref_name == 'master') || - (github.event_name == 'release' && github.event.action == 'released') + (github.event_name == 'release' && github.event.action == 'released') )