| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,11 +6,6 @@ source "${GHA_SCRIPTS_DIR}/.github/workflows/common.sh" | |||
| 6 | 6 | ||
| 7 | 7 | prepare_git_repo | |
| 8 | 8 | ||
| 9 | - if ! check_remote_branch "cacerts-${VERSION_NEW}-${TARGET_BRANCH}"; then | ||
| 10 | - echo "remote branch already exists, nothing to do" | ||
| 11 | - exit 0 | ||
| 12 | - fi | ||
| 13 | - | ||
| 14 | 9 | pushd "${SDK_OUTER_OVERLAY}" | |
| 15 | 10 | ||
| 16 | 11 | # Parse the Manifest file for already present source files and keep the latest version in the current series | |
@@ -32,7 +27,4 @@ generate_update_changelog 'ca-certificates' "${VERSION_NEW}" "${URL}" 'ca-certif | |||
| 32 | 27 | ||
| 33 | 28 | commit_changes app-misc/ca-certificates "${VERSION_OLD}" "${VERSION_NEW}" | |
| 34 | 29 | ||
| 35 | - cleanup_repo | ||
| 36 | - | ||
| 37 | - echo "VERSION_OLD=${VERSION_OLD}" >>"${GITHUB_OUTPUT}" | ||
| 38 | - echo 'UPDATE_NEEDED=1' >>"${GITHUB_OUTPUT}" | ||
| 30 | + push_changes_with_rebase | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,12 +12,11 @@ jobs: | |||
| 12 | 12 | fail-fast: false | |
| 13 | 13 | runs-on: ubuntu-latest | |
| 14 | 14 | steps: | |
| 15 | - - name: Check out main scripts branch for GitHub workflow scripts only | ||
| 15 | + - name: Check out scripts at ${{ github.ref }} for GHA scripts only | ||
| 16 | 16 | uses: actions/checkout@v4 | |
| 17 | 17 | with: | |
| 18 | 18 | token: ${{ secrets.BOT_PR_TOKEN }} | |
| 19 | 19 | path: gha | |
| 20 | - ref: main | ||
| 21 | 20 | - name: Figure out branch | |
| 22 | 21 | id: figure-out-branch | |
| 23 | 22 | run: gha/.github/workflows/figure-out-branch.sh '${{ matrix.channel }}' | |
@@ -55,15 +54,3 @@ jobs: | |||
| 55 | 54 | SDK_NAME: ${{ steps.setup-flatcar-sdk.outputs.SDK_NAME }} | |
| 56 | 55 | TARGET_BRANCH: ${{ steps.figure-out-branch.outputs.BRANCH }} | |
| 57 | 56 | run: gha/.github/workflows/cacerts-apply-patch.sh | |
| 58 | - - name: Create pull request | ||
| 59 | - if: (steps.figure-out-branch.outputs.SKIP == 0) && (steps.apply-patch.outputs.UPDATE_NEEDED == 1) | ||
| 60 | - uses: peter-evans/create-pull-request@v6 | ||
| 61 | - with: | ||
| 62 | - token: ${{ secrets.BOT_PR_TOKEN }} | ||
| 63 | - path: work | ||
| 64 | - branch: "cacerts-${{ steps.nss-latest-release.outputs.NSS_VERSION }}-${{ steps.figure-out-branch.outputs.BRANCH }}" | ||
| 65 | - base: ${{ steps.figure-out-branch.outputs.BRANCH }} | ||
| 66 | - title: Update ca-certificates in ${{ steps.figure-out-branch.outputs.BRANCH }} from ${{ steps.apply-patch.outputs.VERSION_OLD }} to ${{ steps.nss-latest-release.outputs.NSS_VERSION }} | ||
| 67 | - body: Subject says it all. | ||
| 68 | - labels: ${{ steps.figure-out-branch.outputs.LABEL }} | ||
| 69 | - signoff: true | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -279,6 +279,30 @@ jobs: | |||
| 279 | 279 | path: | | |
| 280 | 280 | scripts/image-changes-reports*.txt | |
| 281 | 281 | ||
| 282 | + - name: Post reports to PR | ||
| 283 | + if: github.event.pull_request | ||
| 284 | + uses: actions/github-script@v7 | ||
| 285 | + with: | ||
| 286 | + script: | | ||
| 287 | + const fs = require('fs'); | ||
| 288 | + const globber = await glob.create('scripts/image-changes-reports*.txt'); | ||
| 289 | + let body = `### Image changes reports (${{ matrix.arch }})\n\n`; | ||
| 290 | + for await (const file of globber.globGenerator()) { | ||
| 291 | + const name = require('path').basename(file, '.txt'); | ||
| 292 | + const content = fs.readFileSync(file, 'utf8').trim(); | ||
| 293 | + if (content) { | ||
| 294 | + body += `<details><summary>${name}</summary>\n\n\`\`\`diff\n${content}\n\`\`\`\n\n</details>\n\n`; | ||
| 295 | + } | ||
| 296 | + } | ||
| 297 | + if (body.includes('<details>')) { | ||
| 298 | + await github.rest.issues.createComment({ | ||
| 299 | + owner: context.repo.owner, | ||
| 300 | + repo: context.repo.repo, | ||
| 301 | + issue_number: context.issue.number, | ||
| 302 | + body: body, | ||
| 303 | + }); | ||
| 304 | + } | ||
| 305 | + | ||
| 282 | 306 | # Clean up what we uploaded already so the "vendor images" wildcard | |
| 283 | 307 | # works when uploading artifacts in the next step. | |
| 284 | 308 | - name: Remove update, generic and devcontainer images | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,6 +191,16 @@ function commit_changes() { | |||
| 191 | 191 | popd | |
| 192 | 192 | } | |
| 193 | 193 | ||
| 194 | + # Push the changes to the current remote and branch. If this fails, clean up | ||
| 195 | + # (rebase needs this), pull, and rebase before trying again. | ||
| 196 | + function push_changes_with_rebase() { | ||
| 197 | + if ! git -C "${SDK_OUTER_TOPDIR}" push; then | ||
| 198 | + cleanup_repo | ||
| 199 | + git -C "${SDK_OUTER_TOPDIR}" pull --rebase --depth=500 | ||
| 200 | + git -C "${SDK_OUTER_TOPDIR}" push | ||
| 201 | + fi | ||
| 202 | + } | ||
| 203 | + | ||
| 194 | 204 | # Prints the status of the git repo and cleans it up - reverts | |
| 195 | 205 | # uncommitted changes, removes untracked files. It's usually called at | |
| 196 | 206 | # the end of a script making changes to the repository in order to | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,12 +12,11 @@ jobs: | |||
| 12 | 12 | fail-fast: false | |
| 13 | 13 | runs-on: ubuntu-latest | |
| 14 | 14 | steps: | |
| 15 | - - name: Check out main scripts branch for GitHub workflow scripts only | ||
| 15 | + - name: Check out scripts at ${{ github.ref }} for GHA scripts only | ||
| 16 | 16 | uses: actions/checkout@v4 | |
| 17 | 17 | with: | |
| 18 | 18 | token: ${{ secrets.BOT_PR_TOKEN }} | |
| 19 | 19 | path: gha | |
| 20 | - ref: main | ||
| 21 | 20 | - name: Figure out branch | |
| 22 | 21 | id: figure-out-branch | |
| 23 | 22 | run: gha/.github/workflows/figure-out-branch.sh '${{ matrix.channel }}' | |
@@ -66,5 +65,5 @@ jobs: | |||
| 66 | 65 | base: ${{ steps.figure-out-branch.outputs.BRANCH }} | |
| 67 | 66 | title: Upgrade Linux Kernel for ${{ steps.figure-out-branch.outputs.BRANCH }} from ${{ steps.apply-patch.outputs.VERSION_OLD }} to ${{ steps.kernel-latest-release.outputs.KERNEL_VERSION }} | |
| 68 | 67 | body: Subject says it all. | |
| 69 | - labels: ${{ steps.figure-out-branch.outputs.LABEL }} | ||
| 68 | + labels: ${{ steps.figure-out-branch.outputs.LABEL }},auto-ci | ||
| 70 | 69 | signoff: true | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,82 +1,52 @@ | |||
| 1 | 1 | name: Get the latest mantle release for branch | |
| 2 | 2 | on: | |
| 3 | 3 | workflow_dispatch: | |
| 4 | - push: | ||
| 5 | - branches: | ||
| 6 | - - main | ||
| 7 | 4 | schedule: | |
| 8 | 5 | - cron: '0 7 * * 1' | |
| 9 | 6 | ||
| 10 | 7 | jobs: | |
| 11 | 8 | get-mantle-release: | |
| 12 | 9 | strategy: | |
| 13 | 10 | matrix: | |
| 14 | - branch: [main,alpha,beta,stable,lts,lts-old] | ||
| 11 | + channel: [main,alpha,beta,stable,lts,lts-old] | ||
| 15 | 12 | fail-fast: false | |
| 16 | 13 | runs-on: ubuntu-latest | |
| 17 | 14 | steps: | |
| 15 | + - name: Check out scripts at ${{ github.ref }} for GHA scripts only | ||
| 16 | + uses: actions/checkout@v4 | ||
| 17 | + with: | ||
| 18 | + token: ${{ secrets.BOT_PR_TOKEN }} | ||
| 19 | + path: gha | ||
| 18 | 20 | - name: Figure out branch | |
| 19 | 21 | id: figure-out-branch | |
| 20 | - run: | | ||
| 21 | - set -euo pipefail # The line with major=$(curl | awk) requires pipefail for error handling | ||
| 22 | - skip=0 | ||
| 23 | - branch='' | ||
| 24 | - if [ ${{ matrix.branch }} = "main" ]; then | ||
| 25 | - branch='main' | ||
| 26 | - elif [[ ${{ matrix.branch }} = 'lts-old' ]]; then | ||
| 27 | - curl -fsSLO --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 'https://lts.release.flatcar-linux.net/lts-info' | ||
| 28 | - if [[ $(grep -e ':supported' lts-info | wc -l) -le 1 ]]; then | ||
| 29 | - # Only one supported LTS, skip this workflow run | ||
| 30 | - # as 'lts' matrix branch will handle updating the only | ||
| 31 | - # supported LTS. | ||
| 32 | - skip=1 | ||
| 33 | - else | ||
| 34 | - major=$(grep -e ':supported' lts-info | sort -V | head -n 1 | awk -F: '{print $1}') | ||
| 35 | - branch="flatcar-${major}" | ||
| 36 | - # Drop this corner case when 2605 is not supported. | ||
| 37 | - if [[ ${major} -eq 2605 ]]; then | ||
| 38 | - branch='flatcar-lts-2605' | ||
| 39 | - fi | ||
| 40 | - fi | ||
| 41 | - rm -f lts-info | ||
| 42 | - else | ||
| 43 | - major=$(curl -fsSL --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 https://${{ matrix.branch }}.release.flatcar-linux.net/amd64-usr/current/version.txt | awk -F= '/FLATCAR_BUILD=/{ print $2 }') | ||
| 44 | - branch="flatcar-${major}" | ||
| 45 | - fi | ||
| 46 | - echo "BRANCH=${branch}" >>"${GITHUB_OUTPUT}" | ||
| 47 | - echo "SKIP=${skip}" >>"${GITHUB_OUTPUT}" | ||
| 48 | - - uses: actions/checkout@v4 | ||
| 49 | - if: ${{ steps.figure-out-branch.outputs.SKIP == 0 }} | ||
| 22 | + run: gha/.github/workflows/figure-out-branch.sh '${{ matrix.channel }}' | ||
| 23 | + - name: Check out work scripts branch for updating | ||
| 24 | + if: steps.figure-out-branch.outputs.SKIP == 0 | ||
| 25 | + uses: actions/checkout@v4 | ||
| 50 | 26 | with: | |
| 51 | 27 | token: ${{ secrets.BOT_PR_TOKEN }} | |
| 28 | + path: work | ||
| 52 | 29 | ref: ${{ steps.figure-out-branch.outputs.BRANCH }} | |
| 53 | 30 | - name: Fetch latest mantle hash | |
| 54 | - if: ${{ steps.figure-out-branch.outputs.SKIP == 0 }} | ||
| 31 | + if: steps.figure-out-branch.outputs.SKIP == 0 | ||
| 55 | 32 | id: fetch-latest-mantle | |
| 56 | 33 | run: | | |
| 57 | 34 | set -euo pipefail | |
| 58 | 35 | commit=$(git ls-remote https://github.com/flatcar/mantle refs/heads/main | cut -f1) | |
| 59 | 36 | echo "COMMIT=${commit}" >>"${GITHUB_OUTPUT}" | |
| 60 | 37 | - name: Try to apply patch | |
| 61 | - if: ${{ steps.figure-out-branch.outputs.SKIP == 0 }} | ||
| 38 | + if: steps.figure-out-branch.outputs.SKIP == 0 | ||
| 39 | + env: | ||
| 40 | + WORK_SCRIPTS_DIR: "${{ github.workspace }}/work" | ||
| 62 | 41 | run: | | |
| 63 | 42 | set -euo pipefail | |
| 43 | + source gha/.github/workflows/common.sh | ||
| 64 | 44 | set -x | |
| 45 | + cd "${WORK_SCRIPTS_DIR}" | ||
| 65 | 46 | commit=${{ steps.fetch-latest-mantle.outputs.COMMIT }} | |
| 66 | - if ! grep -q "ghcr.io/flatcar/mantle:git-${commit}" sdk_container/.repo/manifests/mantle-container; then | ||
| 67 | - echo "ghcr.io/flatcar/mantle:git-${commit}" > sdk_container/.repo/manifests/mantle-container | ||
| 68 | - git add sdk_container/.repo/manifests/mantle-container | ||
| 69 | - fi | ||
| 70 | - - name: Create pull request for branch | ||
| 71 | - if: ${{ steps.figure-out-branch.outputs.SKIP == 0 }} | ||
| 72 | - uses: peter-evans/create-pull-request@v6 | ||
| 73 | - with: | ||
| 74 | - token: ${{ secrets.BOT_PR_TOKEN }} | ||
| 75 | - base: ${{ steps.figure-out-branch.outputs.BRANCH }} | ||
| 76 | - branch: mantle-update-${{ steps.figure-out-branch.outputs.BRANCH }} | ||
| 77 | - author: Flatcar Buildbot <buildbot@flatcar-linux.org> | ||
| 78 | - committer: Flatcar Buildbot <buildbot@flatcar-linux.org> | ||
| 79 | - title: Upgrade mantle container image to latest HEAD in ${{ steps.figure-out-branch.outputs.BRANCH }} | ||
| 80 | - commit-message: Update mantle container image to latest HEAD | ||
| 81 | - delete-branch: true | ||
| 82 | - signoff: true | ||
| 47 | + file=sdk_container/.repo/manifests/mantle-container | ||
| 48 | + echo "ghcr.io/flatcar/mantle:git-${commit}" > "${file}" | ||
| 49 | + git status --porcelain "${file}" | grep -q "^ M" || exit 0 | ||
| 50 | + prepare_git_repo | ||
| 51 | + git commit --signoff -m "Update mantle container image to latest HEAD" "${file}" | ||
| 52 | + push_changes_with_rebase | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,40 +10,53 @@ concurrency: | |||
| 10 | 10 | cancel-in-progress: true | |
| 11 | 11 | ||
| 12 | 12 | jobs: | |
| 13 | - pre_check: | ||
| 14 | - name: "Check if we need to update the SDK" | ||
| 13 | + approval_gate: | ||
| 14 | + name: "Wait for approval" | ||
| 15 | 15 | runs-on: ubuntu-latest | |
| 16 | - # Setting the environment is the more important reason we need this job. | ||
| 17 | - # We use this job as a gate, so we can approve the PR workflow only once. If | ||
| 16 | + # Use this job as a gate, so we can approve the PR workflow only once. If | ||
| 18 | 17 | # we set this in the update_sdk job and in the build_image job, we would have | |
| 19 | 18 | # to approve the workflow for every job that kicks off. Given that the jobs | |
| 20 | 19 | # are sequenced, this is cumbersome. Use this job as a gate and make the rest | |
| 21 | 20 | # dependent on it. | |
| 22 | - environment: development | ||
| 23 | - outputs: | ||
| 24 | - sdk_changes: ${{ steps.step1.outputs.sdk_changes }} | ||
| 21 | + # | ||
| 22 | + # Skip the environment gate for auto-ci PRs from the bot to allow | ||
| 23 | + # automatic triggering without manual approval. | ||
| 24 | + environment: ${{ (github.actor != 'flatcar-infra' || !contains(github.event.pull_request.labels.*.name, 'auto-ci')) && 'development' || null }} | ||
| 25 | 25 | steps: | |
| 26 | - - name: Set outputs | ||
| 27 | - id: step1 | ||
| 28 | - shell: bash | ||
| 29 | - run: | | ||
| 30 | - echo "sdk_changes=${{ contains(github.event.pull_request.body, '/update-sdk') }}" >> $GITHUB_OUTPUT | ||
| 26 | + - run: 'true' | ||
| 31 | 27 | ||
| 32 | 28 | update_sdk: | |
| 33 | 29 | name: "Build an updated SDK container" | |
| 34 | - needs: [ pre_check ] | ||
| 35 | - if: needs.pre_check.outputs.sdk_changes == 'true' | ||
| 30 | + needs: [ approval_gate ] | ||
| 31 | + if: "!contains(github.event.pull_request.labels.*.name, 'jenkins-ci') && contains(github.event.pull_request.body, '/update-sdk')" | ||
| 36 | 32 | # SDK build needs access to bincache ssh secret | |
| 37 | 33 | secrets: inherit | |
| 38 | 34 | uses: ./.github/workflows/update-sdk.yaml | |
| 39 | 35 | ||
| 40 | 36 | build_image: | |
| 41 | - needs: [ update_sdk ] | ||
| 37 | + needs: [ approval_gate, update_sdk ] | ||
| 42 | 38 | # The update-sdk job may be skipped, which is fine. We only care if it tried to | |
| 43 | 39 | # run, but failed. | |
| 44 | - if: (always() && !cancelled()) && needs.update_sdk.result != 'failure' | ||
| 40 | + if: "!contains(github.event.pull_request.labels.*.name, 'jenkins-ci') && always() && !cancelled() && needs.approval_gate.result == 'success' && needs.update_sdk.result != 'failure'" | ||
| 45 | 41 | name: "Build the OS image" | |
| 46 | 42 | uses: ./.github/workflows/ci.yaml | |
| 47 | 43 | with: | |
| 48 | 44 | custom_sdk_version: ${{ needs.update_sdk.outputs.sdk_version }} | |
| 49 | 45 | image_formats: qemu_uefi pxe | |
| 46 | + | ||
| 47 | + jenkins_ci: | ||
| 48 | + name: "Trigger Jenkins CI" | ||
| 49 | + needs: [ approval_gate ] | ||
| 50 | + if: contains(github.event.pull_request.labels.*.name, 'jenkins-ci') | ||
| 51 | + runs-on: ubuntu-latest | ||
| 52 | + steps: | ||
| 53 | + - name: Trigger Jenkins build | ||
| 54 | + run: | | ||
| 55 | + curl -fsSL \ | ||
| 56 | + https://jenkins.flatcar.org/buildByToken/buildWithParameters \ | ||
| 57 | + --data-urlencode "token=${{ secrets.JENKINS_REMOTE_TRIGGER_TOKEN }}" \ | ||
| 58 | + --data-urlencode "job=container/packages_all_arches" \ | ||
| 59 | + --data-urlencode "cause=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ | ||
| 60 | + --data-urlencode "version=main-9999.0.${{ github.run_number }}-github-${{ github.event.pull_request.number }}" \ | ||
| 61 | + --data-urlencode "scripts_ref=${{ github.event.pull_request.head.sha }}" \ | ||
| 62 | + --data-urlencode "git_sha=${{ github.event.pull_request.head.sha }}" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments