diff --git a/.gitea/workflows/image.yaml b/.gitea/workflows/image.yaml index 65a836b..07b477e 100644 --- a/.gitea/workflows/image.yaml +++ b/.gitea/workflows/image.yaml @@ -19,16 +19,21 @@ jobs: with: persist-credentials: false - name: Check upstream versions + id: update if: github.event_name != 'push' - run: python3 scripts/update.py + run: | + set -eu + python3 scripts/update.py + if git diff --quiet -- versions.env; then echo changed=false; else echo changed=true; fi >> "$GITHUB_OUTPUT" - name: Build and test + if: github.event_name == 'push' || steps.update.outputs.changed == 'true' run: | set -eu . ./versions.env docker build --pull --build-arg COREDNS_VERSION="$COREDNS_VERSION" --build-arg MYSQL_PLUGIN_REV="$MYSQL_PLUGIN_REV" -f dockerfile -t coredns-mysql:ci . scripts/test-image.sh coredns-mysql:ci "$COREDNS_VERSION" - name: Commit and push updated versions - if: github.event_name != 'push' + if: github.event_name != 'push' && steps.update.outputs.changed == 'true' env: GIT_HOST: ${{ vars.GIT_HOST }} GIT_NAME: ${{ vars.GIT_NAME }} @@ -37,7 +42,6 @@ jobs: GIT_TOKEN: ${{ secrets.GIT_TOKEN }} run: | set -eu - if git diff --quiet -- versions.env; then exit 0; fi test -n "$GIT_HOST" && test -n "$GIT_NAME" && test -n "$GIT_EMAIL" && test -n "$REGISTRY_USER" && test -n "$GIT_TOKEN" git config user.name "$GIT_NAME" git config user.email "$GIT_EMAIL" @@ -49,6 +53,7 @@ jobs: chmod 700 "$askpass" GIT_ASKPASS="$askpass" GIT_TERMINAL_PROMPT=0 git push "https://${GIT_HOST}/${GITHUB_REPOSITORY}.git" HEAD:refs/heads/main - name: Publish image + if: github.event_name == 'push' || steps.update.outputs.changed == 'true' env: GIT_HOST: ${{ vars.GIT_HOST }} REGISTRY_USER: ${{ vars.REGISTRY_USER }}