Skip to content

Commit

Permalink
Gha simplify (#4)
Browse files Browse the repository at this point in the history
* Simplify GHA

* Remove REF in favor of `ref_type`
  • Loading branch information
snovikov authored Dec 22, 2022
1 parent 26e40ec commit c39fb5d
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Build-Publish

on:
push:
branches:
branches: ["**"]
tags-ignore: ["**"]
release:
types: [released]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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')
)

0 comments on commit c39fb5d

Please sign in to comment.