From 01ab9432e496ae517549fb30cb4a15cfd3732f57 Mon Sep 17 00:00:00 2001 From: Pat Date: Mon, 7 Mar 2022 14:47:43 +0000 Subject: [PATCH] workflows: support ref for checkout (#5001) * workflows: support ref for checkout Signed-off-by: Patrick Stephens * workflows: update metadata creation Signed-off-by: Patrick Stephens * workflows: linting Signed-off-by: Patrick Stephens --- .github/workflows/build-master-packages.yaml | 1 + .github/workflows/call-build-images.yaml | 8 +++- .github/workflows/call-build-packages.yaml | 8 +++- .github/workflows/staging-build.yaml | 41 +++++++++++--------- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build-master-packages.yaml b/.github/workflows/build-master-packages.yaml index 5151468ad8b..38c8dcdf705 100644 --- a/.github/workflows/build-master-packages.yaml +++ b/.github/workflows/build-master-packages.yaml @@ -28,6 +28,7 @@ jobs: uses: fluent/fluent-bit/.github/workflows/call-build-packages.yaml@master with: version: master + ref: master branch: master build_matrix: ${{ needs.master-build-generate-matrix.outputs.build-matrix }} secrets: diff --git a/.github/workflows/call-build-images.yaml b/.github/workflows/call-build-images.yaml index 7ea240fc17f..e87ec33d824 100644 --- a/.github/workflows/call-build-images.yaml +++ b/.github/workflows/call-build-images.yaml @@ -5,7 +5,11 @@ on: workflow_call: inputs: version: - description: The version of Fluent Bit to build as a tag, commit, SHA. + description: The version of Fluent Bit to create. + type: string + required: true + ref: + description: The commit, tag or branch of Fluent Bit to checkout for building that creates the version above. type: string required: true registry: @@ -51,7 +55,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - ref: ${{ inputs.version }} + ref: ${{ inputs.ref }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 diff --git a/.github/workflows/call-build-packages.yaml b/.github/workflows/call-build-packages.yaml index d38af40223c..4b20e7831c3 100644 --- a/.github/workflows/call-build-packages.yaml +++ b/.github/workflows/call-build-packages.yaml @@ -5,7 +5,11 @@ on: workflow_call: inputs: version: - description: The version of Fluent Bit to build as a tag, commit, SHA. + description: The version of Fluent Bit to create. + type: string + required: true + ref: + description: The commit, tag or branch of Fluent Bit to checkout for building that creates the version above. type: string required: true build_matrix: @@ -57,7 +61,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - ref: ${{ inputs.version }} + ref: ${{ inputs.ref }} - name: Set up QEMU uses: docker/setup-qemu-action@v1 diff --git a/.github/workflows/staging-build.yaml b/.github/workflows/staging-build.yaml index c74c044552e..ccb9dac46ea 100644 --- a/.github/workflows/staging-build.yaml +++ b/.github/workflows/staging-build.yaml @@ -27,17 +27,20 @@ concurrency: staging-build-release jobs: - # This job copes with the variable approach of either being triggered by a tag, - # where the data is then in the reference provided, or by a manual event where - # the data is then in another structure entirely. We take the manual input if - # it is present, otherwise we try to figure it out. - staging-build-get-version: - name: Get version to build + # This job strips off the `v` at the start of any tag provided. + # It then provides this metadata for the other jobs to use. + staging-build-get-meta: + name: Get metadata to build runs-on: ubuntu-latest outputs: version: ${{ steps.formatted_version.outputs.replaced }} date: ${{ steps.date.outputs.date }} steps: + + - run: | + echo "Version: ${{ github.event.inputs.version || github.ref_name }}" + shell: bash + # This step is to consolidate the three different triggers into a single "version" # 1. If manual dispatch - use the version provided. # 2. If cron/regular build - use master. @@ -72,15 +75,16 @@ jobs: run: echo "::set-output name=date::$(date '+%Y-%m-%d-%H_%M_%S')" staging-build-images: - needs: staging-build-get-version + needs: staging-build-get-meta uses: fluent/fluent-bit/.github/workflows/call-build-images.yaml@master with: - version: ${{ needs.staging-build-get-version.outputs.version }} + version: ${{ needs.staging-build-get-meta.outputs.version }} + ref: ${{ github.event.inputs.version || github.ref_name }} registry: ghcr.io username: ${{ github.actor }} image: ${{ github.repository }}/staging environment: staging - unstable: ${{ github.event_name == 'schedule' && needs.staging-build-get-version.outputs.date || '' }} + unstable: ${{ github.event_name == 'schedule' && needs.staging-build-get-meta.outputs.date || '' }} secrets: token: ${{ secrets.GITHUB_TOKEN }} cosign_private_key: ${{ secrets.COSIGN_PRIVATE_KEY }} @@ -118,13 +122,14 @@ jobs: shell: bash staging-build-packages: - needs: [ staging-build-get-version, staging-build-generate-matrix ] + needs: [ staging-build-get-meta, staging-build-generate-matrix ] uses: fluent/fluent-bit/.github/workflows/call-build-packages.yaml@master with: - version: ${{ needs.staging-build-get-version.outputs.version }} + version: ${{ needs.staging-build-get-meta.outputs.version }} + ref: ${{ github.event.inputs.version || github.ref_name }} build_matrix: ${{ needs.staging-build-generate-matrix.outputs.build-matrix }} environment: staging - unstable: ${{ github.event_name == 'schedule' && needs.staging-build-get-version.outputs.date || '' }} + unstable: ${{ github.event_name == 'schedule' && needs.staging-build-get-meta.outputs.date || '' }} secrets: token: ${{ secrets.GITHUB_TOKEN }} bucket: ${{ secrets.AWS_S3_BUCKET_STAGING }} @@ -137,7 +142,7 @@ jobs: staging-unstable-release: runs-on: ubuntu-latest needs: - - staging-build-get-version + - staging-build-get-meta - staging-build-images - staging-build-packages environment: staging @@ -153,7 +158,7 @@ jobs: - name: Single packages tar run: | mkdir -p release-upload - tar -czvf release-upload/packages-unstable-${{ needs.staging-build-get-version.outputs.version }}.tar.gz -C artifacts/ . + tar -czvf release-upload/packages-unstable-${{ needs.staging-build-get-meta.outputs.version }}.tar.gz -C artifacts/ . shell: bash - name: Log in to the Container registry @@ -167,10 +172,10 @@ jobs: # May not be any/valid so ignore errors continue-on-error: true run: | - docker pull ghcr.io/${{ github.repository }}/staging:${{ needs.staging-build-get-version.outputs.version }} - docker save --output container-${{ needs.staging-build-get-version.outputs.version }}.tar ghcr.io/${{ github.repository }}/staging:${{ needs.staging-build-get-version.outputs.version }} - docker pull ghcr.io/${{ github.repository }}/staging:${{ needs.staging-build-get-version.outputs.version }}-debug - docker save --output container-${{ needs.staging-build-get-version.outputs.version }}-debug.tar ghcr.io/${{ github.repository }}/staging:${{ needs.staging-build-get-version.outputs.version }}-debug + docker pull ghcr.io/${{ github.repository }}/staging:${{ needs.staging-build-get-meta.outputs.version }} + docker save --output container-${{ needs.staging-build-get-meta.outputs.version }}.tar ghcr.io/${{ github.repository }}/staging:${{ needs.staging-build-get-meta.outputs.version }} + docker pull ghcr.io/${{ github.repository }}/staging:${{ needs.staging-build-get-meta.outputs.version }}-debug + docker save --output container-${{ needs.staging-build-get-meta.outputs.version }}-debug.tar ghcr.io/${{ github.repository }}/staging:${{ needs.staging-build-get-meta.outputs.version }}-debug shell: bash working-directory: release-upload