From d5fae5f1cc11c99295d7075c9094fc253aacb009 Mon Sep 17 00:00:00 2001 From: robe-rt Date: Wed, 8 Jan 2025 14:26:50 +0100 Subject: [PATCH 1/2] ci: push test images tagged with git sha --- .github/workflows/push.yaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index f9abed1..e7ca78b 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -55,7 +55,7 @@ jobs: - name: Add missing license headers run: nwa add -c "Syntio Ltd." -s **/*.xml ./registry ./validator - - name: Check and Commit changes + - name: Check and commit changes id: check_commit run: | git config user.name "github-actions[bot]" @@ -75,7 +75,7 @@ jobs: git checkout -b "add-license-headers-${{ github.run_id }}" git push origin HEAD - - name: Create Pull Request + - name: Create pull request if: env.changes_committed == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -84,7 +84,6 @@ jobs: upload_docker_images_job: name: Build, push and sign Docker images - if: github.event.head_commit.committer.name == 'github-actions[bot]' runs-on: ubuntu-latest permissions: id-token: write # required to generate JWT token @@ -111,9 +110,13 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - name: Set Tag + - name: Set image tag run: | - TAG=$(cat version.txt) + if [ ${{ github.event.head_commit.committer.name }} == 'github-actions[bot]' ]; then + TAG=$(cat version.txt) + else + TAG=$(echo $GITHUB_SHA | cut -c 1-7) + fi echo "TAG=$TAG" >> $GITHUB_ENV - name: Docker Hub Login @@ -139,11 +142,11 @@ jobs: docker push syntioinc/dataphos-${{ matrix.component.image-name }}:${{ env.TAG }} - name: Install cosign - if: ${{ env.TAG_EXISTS == 'false' }} + if: ${{ github.event.head_commit.committer.name == 'github-actions[bot]' && env.TAG_EXISTS == 'false' }} uses: sigstore/cosign-installer@v3.6.0 - name: Sign the Docker image - if: ${{ env.TAG_EXISTS == 'false' }} + if: ${{ github.event.head_commit.committer.name == 'github-actions[bot]' && env.TAG_EXISTS == 'false' }} run: | digest=$(docker inspect --format='{{index .RepoDigests 0}}' syntioinc/dataphos-${{ matrix.component.image-name }}:${{ env.TAG }}) cosign sign --yes "$digest" From ccdcd4d83fb3c450036ba2eefb513c29182c9271 Mon Sep 17 00:00:00 2001 From: robe-rt Date: Wed, 8 Jan 2025 17:15:31 +0100 Subject: [PATCH 2/2] ci: run docker build on feat, fix and release --- .github/workflows/push.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index e7ca78b..7055e80 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -83,6 +83,7 @@ jobs: gh pr create --base ${{ github.ref_name }} --head "add-license-headers-${{ github.run_id }}" --title "style: add license headers" --body "This PR adds license headers to the affected files. Recommendation: Merge this PR using the rebase-merge method" upload_docker_images_job: + if: github.event.head_commit.committer.name == 'github-actions[bot]' || startsWith(github.event.head_commit.message.name, 'feat') || startsWith(github.event.head_commit.message.name, 'fix') name: Build, push and sign Docker images runs-on: ubuntu-latest permissions: