diff --git a/.github/actions/detect/action.yaml b/.github/actions/detect/action.yaml index 4a42e01..c4ffd54 100644 --- a/.github/actions/detect/action.yaml +++ b/.github/actions/detect/action.yaml @@ -1,5 +1,5 @@ name: Detect changes -description: +description: Note the action can't hande force pushes. Force push should be handled by the caller by finding the merge-base and passing that as before input instead of the github.event.before. inputs: path: @@ -11,9 +11,6 @@ inputs: before: required: true description: before sha - is_forced: - required: true - description: github.event.forced base_image_changed: required: true description: bool true if base image changed, false otherwise @@ -31,18 +28,18 @@ runs: steps: - id: changes-push name: detect pushed changes - if: inputs.is_forced == 'false' uses: tj-actions/changed-files@v45 with: files: ${{ inputs.path }} + base_sha: ${{ inputs.before }} - id: changes-branch name: detect branch changes - if: inputs.is_forced == 'false' && - steps.changes-push.outputs.any_changed == 'false' + if: steps.changes-push.outputs.any_changed == 'false' uses: tj-actions/changed-files@v45 with: files: ${{ inputs.path }} + base_sha: ${{ inputs.default_branch }} - id: tag name: determine tags diff --git a/.github/determine-tag.sh b/.github/determine-tag.sh index 03834d5..088be02 100755 --- a/.github/determine-tag.sh +++ b/.github/determine-tag.sh @@ -1,11 +1,5 @@ #! /usr/bin/sh -$is_forced && { - printf "tag=%s\n" "$sha" - printf "changed=true\n" - exit 0 -} - $base_image_changed && { printf "tag=%s\n" "$sha" printf "changed=true\n" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6a1690e..ecad416 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -49,6 +49,10 @@ jobs: branch_tag: ${{ steps.branch-tag.outputs.branch_tag }} + env: + before: ${{ github.event.before }} + sha: ${{ github.sha }} + steps: - uses: actions/checkout@v4 with: @@ -57,6 +61,13 @@ jobs: # whatever amount it actually needs. fetch-depth: 0 + - name: find proper before if forced + if: github.event.forced + run: | + git fetch origin "$before" + base=$(git merge-base "$before" "$sha") || exit 1 + printf "before=%s" $base >> $GITHUB_ENV + - id: branch-tag name: Sanitize ref_name into a valid tag token env: @@ -73,8 +84,7 @@ jobs: with: path: telemetry/postgres/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: false - id: changed-mq-base-debian @@ -83,8 +93,7 @@ jobs: with: path: message-queue/container/base-debian/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: false - id: changed-mq-base-debian-testing @@ -93,8 +102,7 @@ jobs: with: path: message-queue/container/base-debian-testing/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: false - id: changed-mq-base-haskell @@ -103,8 +111,7 @@ jobs: with: path: message-queue/container/base-haskell/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: ${{ steps.changed-mq-base-debian.outputs.changed }} - id: changed-mq-postgres @@ -113,8 +120,7 @@ jobs: with: path: message-queue/container/postgres/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: false - id: changed-mq-producer-cpp @@ -123,8 +129,7 @@ jobs: with: path: message-queue/cpp/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: ${{ steps.changed-mq-base-debian.outputs.changed }} - id: changed-mq-producer-golang @@ -133,8 +138,7 @@ jobs: with: path: message-queue/golang/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: ${{ steps.changed-mq-base-debian.outputs.changed }} - id: changed-mq-producer-haskell @@ -143,8 +147,7 @@ jobs: with: path: mesage-queue/haskell/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: ${{ steps.changed-mq-base-debian.outputs.changed }} - id: changed-mq-producer-python @@ -153,8 +156,7 @@ jobs: with: path: message-queue/python/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: ${{ steps.changed-mq-base-debian.outputs.changed }} - id: changed-mq-producer-rust @@ -163,8 +165,7 @@ jobs: with: path: message-queue/rust/** branch_tag: ${{ env.branch_tag }} - before: ${{ github.event.before }} - is_forced: ${{ github.event.forced }} + before: ${{ env.before }} base_image_changed: ${{ steps.changed-mq-base-debian-testing.outputs.changed }} build-base-debian: