Skip to content

Commit

Permalink
ci: Change to login and push only when push is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
abetomo committed Dec 6, 2024
1 parent 7a76026 commit 2456ae1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,21 @@ jobs:
if [ ${{ matrix.id }} = "debian" -a "${version}" = "latest" ]; then
tags="${tags},groonga/groonga:latest"
fi
need_push="no"
if [ "${GITHUB_EVENT_NAME}" = "push" ]; then
need_push="yes"
if [ "${GITHUB_REF_TYPE}" = "tag" ] && [ "${version}" != "${GITHUB_REF_NAME}" ]; then
need_push="no"
fi
fi
echo "DISTRIBUTION=${distribution}" >> ${GITHUB_ENV}
echo "CONTEXT=./${distribution}" >> ${GITHUB_ENV}
echo "TAGS=${tags}" >> ${GITHUB_ENV}
echo "NEED_PUSH=${need_push}" >> ${GITHUB_ENV}
- uses: actions/checkout@v4
- uses: docker/login-action@v3
if: env.NEED_PUSH == 'yes'
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
Expand All @@ -52,7 +62,7 @@ jobs:
# cache-from: type=gha
# cache-to: type=gha,mode=max
context: ${{ env.CONTEXT }}
push: true
push: ${{ env.NEED_PUSH == 'yes' }}
tags: ${{ env.TAGS }}
- name: Image info
run: |
Expand Down

0 comments on commit 2456ae1

Please sign in to comment.