From 867a55b1e7aa72236c47ce91e37699bd6e451a30 Mon Sep 17 00:00:00 2001 From: Flavien Darche Date: Wed, 6 Nov 2024 14:21:34 +0100 Subject: [PATCH] Update the action --- .../workflows/service-extensions-publish.yml | 70 ++++++------------- 1 file changed, 21 insertions(+), 49 deletions(-) diff --git a/.github/workflows/service-extensions-publish.yml b/.github/workflows/service-extensions-publish.yml index 9e0c645be0..d01940d3cc 100644 --- a/.github/workflows/service-extensions-publish.yml +++ b/.github/workflows/service-extensions-publish.yml @@ -2,11 +2,8 @@ name: Publish Service Extensions Callout images packages on: push: - branches: - - 'flavien/service-extensions' - release: - types: - - published + tags: + - '*' workflow_dispatch: inputs: tag_name: @@ -16,44 +13,29 @@ on: commit_sha: description: 'Commit SHA to checkout' required: true + set_as_latest: + description: 'Set the tag as latest' + required: false + default: 'false' permissions: contents: read packages: write +env: + TAG_NAME: ${{ github.ref_name || github.event.inputs.tag_name }} + REF_NAME: ${{ github.ref || github.event.inputs.commit_sha }} + COMMIT_SHA: ${{ github.sha || github.event.inputs.commit_sha }} + PUSH_LATEST: ${{ github.event.inputs.set_as_latest || 'true' }} + jobs: publish-service-extensions: runs-on: ubuntu-latest steps: - - - name: Get tag name - id: get_tag_name - run: | - if [ "${{ github.event_name }}" = "release" ]; then - echo "::set-output name=tag::${{ github.event.release.tag_name }}" - echo "Here1: tag=${{ github.event.release.tag_name }}" - else - if [ -z "${{ github.event.inputs.tag_name }}" ]; then - echo "::set-output name=tag::dev" - echo "Here2: tag=dev" - else - echo "::set-output name=tag::${{ github.event.inputs.tag_name }}" - echo "Here3: tag=${{ github.event.inputs.tag_name }}" - fi - fi - echo "Finally: ${{ steps.get_tag_name.outputs.tag }}" - - - name: Checkout - uses: actions/checkout@v4 - if: github.event_name == 'release' - with: - ref: ${{ steps.get_tag_name.outputs.tag }} - - name: Checkout uses: actions/checkout@v4 - if: github.event_name != 'release' with: - ref: ${{ github.event.inputs.commit_sha || github.sha }} + ref: ${{ env.REF_NAME }} - name: Set up Go 1.22 uses: actions/setup-go@v5 @@ -71,22 +53,12 @@ jobs: shell: bash run: docker login -u publisher -p ${{ secrets.GITHUB_TOKEN }} ghcr.io - - name: Build and push [dev] - id: build-dev - if: github.event_name != 'release' - uses: docker/build-push-action@v6 - with: - context: . - file: ./contrib/envoyproxy/envoy/cmd/serviceextensions/Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: | # Use the commit SHA from the manual trigger or default to the SHA from the push event - ghcr.io/datadog/dd-trace-go/service-extensions-callout:${{ steps.get_tag_name.outputs.tag }} - ghcr.io/datadog/dd-trace-go/service-extensions-callout:${{ github.event.inputs.commit_sha || github.sha }} + - name: Replace slashes in ref name + id: replace_ref + run: echo "TAG_NAME=${TAG_NAME//\//-}" >> $GITHUB_ENV - - name: Build and push [release] - id: build-release - if: github.event_name == 'release' + - name: Build and push + id: build uses: docker/build-push-action@v6 with: context: . @@ -94,6 +66,6 @@ jobs: platforms: linux/amd64,linux/arm64 push: true tags: | - ghcr.io/datadog/dd-trace-go/service-extensions-callout:latest - ghcr.io/datadog/dd-trace-go/service-extensions-callout:${{ steps.get_tag_name.outputs.tag }} - ghcr.io/datadog/dd-trace-go/service-extensions-callout:${{ github.sha }} \ No newline at end of file + ghcr.io/datadog/dd-trace-go/service-extensions-callout:${{ env.TAG_NAME }} + ghcr.io/datadog/dd-trace-go/service-extensions-callout:${{ env.COMMIT_SHA }} + ${{ env.PUSH_LATEST == 'true' && 'ghcr.io/datadog/dd-trace-go/service-extensions-callout:latest' }}