Skip to content

Commit

Permalink
workflows: support ref for checkout (#5001)
Browse files Browse the repository at this point in the history
* workflows: support ref for checkout

Signed-off-by: Patrick Stephens <[email protected]>

* workflows: update metadata creation

Signed-off-by: Patrick Stephens <[email protected]>

* workflows: linting

Signed-off-by: Patrick Stephens <[email protected]>
  • Loading branch information
patrick-stephens authored Mar 7, 2022
1 parent f2e2295 commit 01ab943
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-master-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/call-build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/call-build-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
41 changes: 23 additions & 18 deletions .github/workflows/staging-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 01ab943

Please sign in to comment.