Skip to content

Commit

Permalink
.github:
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-matejka committed Jan 29, 2025
1 parent 264718b commit e9801ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 33 deletions.
11 changes: 4 additions & 7 deletions .github/actions/detect/action.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 0 additions & 6 deletions .github/determine-tag.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
41 changes: 21 additions & 20 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit e9801ab

Please sign in to comment.