From 2456ae188843d84c832a57840712b06b873be4a6 Mon Sep 17 00:00:00 2001 From: Abe Tomoaki Date: Fri, 6 Dec 2024 12:00:40 +0900 Subject: [PATCH 1/2] ci: Change to login and push only when push is needed --- .github/workflows/build.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a1f1e0..56892fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 }} @@ -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: | From 6df0a4bd6c0d92f6d7659c1939511de340e71012 Mon Sep 17 00:00:00 2001 From: Abe Tomoaki Date: Fri, 6 Dec 2024 14:14:53 +0900 Subject: [PATCH 2/2] Remove unnecessary condition --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56892fb..2342f77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,9 +40,6 @@ jobs: 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}