mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-28 09:01:55 +02:00
Refactor workflows
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
0513a6e82c
commit
215fb8f823
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -1,6 +1,5 @@
|
|||||||
name: "Run build"
|
name: "Run build"
|
||||||
on:
|
on:
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
image_formats:
|
image_formats:
|
||||||
@ -30,7 +29,7 @@ on:
|
|||||||
Custom SDK container version to use for this build.
|
Custom SDK container version to use for this build.
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
packages:
|
packages:
|
||||||
@ -40,7 +39,6 @@ jobs:
|
|||||||
- debian
|
- debian
|
||||||
- build
|
- build
|
||||||
- x64
|
- x64
|
||||||
environment: main
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -11,18 +11,18 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check_maintainer_membership:
|
run_pre_checks:
|
||||||
# Only run if this is a PR comment that contains a valid command
|
# Only run if this is a PR comment that contains a valid command
|
||||||
if: |
|
if: ${{ github.event.issue.pull_request }} && contains(github.event.comment.body, '/build-image')
|
||||||
${{ github.event.issue.pull_request }} &&
|
|
||||||
( contains(github.event.comment.body, '/update-sdk') || contains(github.event.comment.body, '/build-image') )
|
|
||||||
name: Check if commenter is in the Flatcar maintainers team
|
name: Check if commenter is in the Flatcar maintainers team
|
||||||
outputs:
|
outputs:
|
||||||
maintainers: steps.step1.output.maintainers
|
maintainers: steps.step1.output.maintainers
|
||||||
|
sdk_changes: steps.step3.outputs.sdk_changes
|
||||||
runs-on:
|
runs-on:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch members of the maintainers team
|
- name: Fetch members of the maintainers team
|
||||||
|
id: step1
|
||||||
env:
|
env:
|
||||||
requester: ${{ github.event.comment.user.login }}
|
requester: ${{ github.event.comment.user.login }}
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -49,25 +49,45 @@ jobs:
|
|||||||
|
|
||||||
$res
|
$res
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
id: step2
|
||||||
|
with:
|
||||||
|
path: scripts
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: dorny/paths-filter@v2
|
||||||
|
id: filter
|
||||||
|
with:
|
||||||
|
working-directory: scripts
|
||||||
|
filters: |
|
||||||
|
sdk_changes:
|
||||||
|
- 'sdk_container/**'
|
||||||
|
- 'sdk_libs/**'
|
||||||
|
|
||||||
|
- name: Set outputs
|
||||||
|
id: step3
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "sdk_changes=${{ steps.filter.outputs.sdk_changes }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Post a link to the workflow run to the PR
|
- name: Post a link to the workflow run to the PR
|
||||||
|
id: step4
|
||||||
uses: mshick/add-pr-comment@v2
|
uses: mshick/add-pr-comment@v2
|
||||||
with:
|
with:
|
||||||
issue: ${{ github.event.issue.pull_request.number }}
|
issue: ${{ github.event.issue.pull_request.number }}
|
||||||
message: "Build action triggered: [${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
message: "Build action triggered: [${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
|
||||||
|
|
||||||
update_sdk:
|
update_sdk:
|
||||||
needs: check_maintainer_membership
|
needs: run_pre_checks
|
||||||
if: ( needs.check_maintainer_membership.result == 'success'
|
if: needs.run_pre_checks.result == 'success' && needs.run_pre_checks.outputs.sdk_changes == 'true'
|
||||||
&& contains(github.event.comment.body, '/update-sdk') )
|
|
||||||
name: "Build an updated SDK container"
|
name: "Build an updated SDK container"
|
||||||
# SDK build needs access to bincache ssh secret
|
# SDK build needs access to bincache ssh secret
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
uses: ./.github/workflows/update-sdk.yaml
|
uses: ./.github/workflows/update-sdk.yaml
|
||||||
|
|
||||||
build_image:
|
build_image:
|
||||||
needs: [ check_maintainer_membership, update_sdk ]
|
needs: [ run_pre_checks, update_sdk ]
|
||||||
if: ( needs.check_maintainer_membership.result == 'success'
|
if: (always() && ! cancelled()) && needs.run_pre_checks.result == 'success' && contains(github.event.comment.body, '/build-image')
|
||||||
&& ( contains(github.event.comment.body, '/build-image') || needs.update_sdk.result == 'success' ) )
|
|
||||||
name: "Build the OS image"
|
name: "Build the OS image"
|
||||||
uses: ./.github/workflows/ci.yaml
|
uses: ./.github/workflows/ci.yaml
|
||||||
with:
|
with:
|
||||||
|
56
.github/workflows/pr-workflows.yaml
vendored
Normal file
56
.github/workflows/pr-workflows.yaml
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
name: "Run PR workflows"
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-pr-${{ github.head_ref || github.ref_name }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_for_sdk_changes:
|
||||||
|
name: "Check for SDK changes"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: development
|
||||||
|
outputs:
|
||||||
|
sdk_changes: ${{ steps.step2.outputs.sdk_changes }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
id: step1
|
||||||
|
with:
|
||||||
|
path: scripts
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: dorny/paths-filter@v2
|
||||||
|
id: filter
|
||||||
|
with:
|
||||||
|
working-directory: scripts
|
||||||
|
filters: |
|
||||||
|
sdk_changes:
|
||||||
|
- 'sdk_container/**'
|
||||||
|
- 'sdk_libs/**'
|
||||||
|
|
||||||
|
- name: Set outputs
|
||||||
|
id: step2
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "sdk_changes=${{ steps.filter.outputs.sdk_changes }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
update_sdk:
|
||||||
|
name: "Build an updated SDK container"
|
||||||
|
needs: [ check_for_sdk_changes ]
|
||||||
|
if: needs.check_for_sdk_changes.sdk_changes == 'true'
|
||||||
|
# SDK build needs access to bincache ssh secret
|
||||||
|
secrets: inherit
|
||||||
|
uses: ./.github/workflows/update-sdk.yaml
|
||||||
|
|
||||||
|
build_image:
|
||||||
|
needs: [ update_sdk ]
|
||||||
|
if: (always() && ! cancelled()) && needs.update_sdk.result != 'failure'
|
||||||
|
name: "Build the OS image"
|
||||||
|
uses: ./.github/workflows/ci.yaml
|
||||||
|
with:
|
||||||
|
custom_sdk_version: ${{ needs.update_sdk.outputs.sdk_version }}
|
||||||
|
image_formats: qemu_uefi
|
Loading…
x
Reference in New Issue
Block a user