From d29f8f49ce90519467a6aeb394417fb2a794a073 Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Wed, 25 Dec 2024 21:07:37 +0300 Subject: [PATCH] feat: publish containers on add-tag --- .github/workflows/add-tag.yml | 6 +++++- .github/workflows/build-containers.yml | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/add-tag.yml b/.github/workflows/add-tag.yml index 9310e6c..39c0a78 100644 --- a/.github/workflows/add-tag.yml +++ b/.github/workflows/add-tag.yml @@ -21,6 +21,10 @@ jobs: - name: Create tag run: | git tag ${{ github.event.client_payload.tag }} - git push --tags + git push origin ${{ github.event.client_payload.tag }} env: GITHUB_TOKEN: ${{ secrets.TEBAKO_CI_PAT_TOKEN }} + + - name: Set output + id: set_output + run: echo "::set-output name=tag::v${{ github.event.client_payload.tag }}" diff --git a/.github/workflows/build-containers.yml b/.github/workflows/build-containers.yml index ab47576..b04783a 100644 --- a/.github/workflows/build-containers.yml +++ b/.github/workflows/build-containers.yml @@ -37,6 +37,23 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Get latest tag + if: github.event_name == 'workflow_run' + id: get_latest_tag + uses: actions/github-script@v7 + with: + script: | + const latestTag = await github.repos.listTags({ + owner: context.repo.owner, + repo: context.repo.repo, + per_page: 1 + }); + core.setOutput('latest_tag', latestTag.data[0].name); + + - name: Set GITHUB_REF + if: github.event_name == 'workflow_run' + run: echo "GITHUB_REF=refs/tags/${{ steps.get_latest_tag.outputs.latest_tag }}" >> $GITHUB_ENV + - name: Log in to the Container registry uses: docker/login-action@v3 with: @@ -66,7 +83,7 @@ jobs: with: context: . file: ./${{ matrix.container }}.Dockerfile - push: ${{ contains(github.ref, 'refs/tags/v') }} + push: ${{ contains(github.ref, 'refs/tags/v') || github.event_name == 'workflow_run' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -82,7 +99,7 @@ jobs: test-packaging-in-container: name: Package ${{ matrix.gem }} in ${{ matrix.container }} with Ruby ${{ matrix.package_ruby_ver }} - if: contains(github.ref, 'refs/tags/v') + if: contains(github.ref, 'refs/tags/v') || github.event_name == 'workflow_run' runs-on: ubuntu-20.04 needs: build-amd64-containers strategy: @@ -114,7 +131,7 @@ jobs: test-packaging-by-container: name: Package ${{ matrix.gem }} by ${{ matrix.container }} container with Ruby ${{ matrix.package_ruby_ver }} - if: contains(github.ref, 'refs/tags/v') + if: contains(github.ref, 'refs/tags/v') || github.event_name == 'workflow_run' runs-on: ubuntu-20.04 needs: build-amd64-containers strategy: