2023-03-21 14:04:36 +01:00
|
|
|
name: Build and Upload OS image (scheduled)
|
2023-01-23 10:59:17 +01:00
|
|
|
|
|
|
|
on:
|
2023-04-13 17:44:23 +02:00
|
|
|
workflow_dispatch:
|
2023-01-23 10:59:17 +01:00
|
|
|
schedule:
|
2023-04-13 17:44:23 +02:00
|
|
|
- cron: "0 21 * * 2" # At 21:00 on Tuesday.
|
|
|
|
- cron: "20 21 * * 2" # At 21:20 on Tuesday.
|
2024-08-07 13:27:06 +02:00
|
|
|
- cron: "40 21 * * 2" # At 21:40 on Tuesday.
|
2023-04-13 17:44:23 +02:00
|
|
|
- cron: "0 21 * * 4" # At 21:00 on Thursday.
|
|
|
|
- cron: "20 21 * * 4" # At 21:20 on Thursday.
|
2024-08-07 13:27:06 +02:00
|
|
|
- cron: "40 21 * * 4" # At 21:40 on Thursday.
|
2023-01-23 10:59:17 +01:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
stream:
|
2024-10-09 12:16:10 +02:00
|
|
|
runs-on: ubuntu-24.04
|
2023-01-23 10:59:17 +01:00
|
|
|
outputs:
|
|
|
|
stream: ${{ steps.stream.outputs.stream }}
|
|
|
|
steps:
|
|
|
|
- name: Determine stream
|
|
|
|
id: stream
|
|
|
|
run: |
|
2023-04-13 17:44:23 +02:00
|
|
|
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
|
|
|
|
echo "stream=nightly" | tee -a "$GITHUB_OUTPUT"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-01-23 10:59:17 +01:00
|
|
|
case "${{ github.event.schedule }}" in
|
2023-04-28 12:57:11 +02:00
|
|
|
"0 21 * * 4" | "0 21 * * 2")
|
2023-04-14 18:25:53 +02:00
|
|
|
echo "stream=debug" | tee -a "$GITHUB_OUTPUT"
|
2023-01-23 10:59:17 +01:00
|
|
|
;;
|
2024-08-07 13:27:06 +02:00
|
|
|
"20 21 * * 4" | "20 21 * * 2")
|
2023-04-14 18:25:53 +02:00
|
|
|
echo "stream=console" | tee -a "$GITHUB_OUTPUT"
|
2023-01-23 10:59:17 +01:00
|
|
|
;;
|
2024-08-07 13:27:06 +02:00
|
|
|
"40 21 * * 4" | "40 21 * * 2")
|
2023-04-14 18:25:53 +02:00
|
|
|
echo "stream=nightly" | tee -a "$GITHUB_OUTPUT"
|
2023-01-23 10:59:17 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "::error::Unknown stream for schedule '${{ github.event.schedule }}'"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
build-image:
|
|
|
|
needs: stream
|
|
|
|
uses: ./.github/workflows/build-os-image.yml
|
2023-01-30 16:11:27 +01:00
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
contents: read
|
|
|
|
packages: read
|
2023-01-23 10:59:17 +01:00
|
|
|
secrets: inherit
|
|
|
|
with:
|
|
|
|
stream: ${{ needs.stream.outputs.stream }}
|
2023-04-13 17:44:23 +02:00
|
|
|
ref: ${{ github.head_ref }}
|
|
|
|
|
|
|
|
update-code:
|
|
|
|
# On nightly stream only.
|
2024-08-07 13:27:06 +02:00
|
|
|
if: needs.stream.outputs.stream == 'nightly'
|
|
|
|
needs: ["build-image", "stream"]
|
2024-10-09 12:16:10 +02:00
|
|
|
runs-on: ubuntu-24.04
|
2023-04-13 17:44:23 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-06-19 15:19:41 +02:00
|
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
2023-04-13 17:44:23 +02:00
|
|
|
with:
|
|
|
|
ref: ${{ github.head_ref }}
|
2024-06-05 10:41:19 +02:00
|
|
|
token: ${{ secrets.CI_COMMIT_PUSH_PR }}
|
2023-04-13 17:44:23 +02:00
|
|
|
|
|
|
|
- name: Setup Go environment
|
2024-07-18 08:49:57 +02:00
|
|
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
|
2023-04-13 17:44:23 +02:00
|
|
|
with:
|
2024-09-09 12:45:48 +02:00
|
|
|
go-version: "1.22.7"
|
2023-06-01 15:16:00 +02:00
|
|
|
cache: false
|
2023-04-13 17:44:23 +02:00
|
|
|
|
|
|
|
- name: Determine version
|
|
|
|
id: version
|
|
|
|
uses: ./.github/actions/pseudo_version
|
|
|
|
|
|
|
|
- name: Update QEMU/MiniConstellation image version
|
2023-05-05 13:13:51 +02:00
|
|
|
run: |
|
|
|
|
defaultVersionReg='defaultImage = \"[^\"]*\"'
|
|
|
|
|
|
|
|
# Ensure regexp matches (otherwise the file was changed or the workflow is broken).
|
2023-05-23 10:49:47 +02:00
|
|
|
grep -E "${defaultVersionReg}" internal/config/image_enterprise.go
|
2023-05-05 13:13:51 +02:00
|
|
|
|
|
|
|
# Update version.
|
|
|
|
newVersion="ref\/${{ steps.version.outputs.branchName }}\/stream\/nightly\/${{ steps.version.outputs.version }}"
|
2023-05-23 10:49:47 +02:00
|
|
|
sed -i "s/${defaultVersionReg}/defaultImage = \"${newVersion}\"/" internal/config/image_enterprise.go
|
2023-04-13 17:44:23 +02:00
|
|
|
|
|
|
|
- name: Build generateMeasurements tool
|
|
|
|
working-directory: internal/attestation/measurements/measurement-generator
|
|
|
|
run: go build -o generate .
|
|
|
|
|
|
|
|
- name: Update hardcoded measurements
|
|
|
|
working-directory: internal/attestation/measurements
|
|
|
|
run: ./measurement-generator/generate
|
|
|
|
|
|
|
|
- name: Cleanup
|
|
|
|
run: rm -f internal/attestation/measurements/measurement-generator/generate
|
|
|
|
|
|
|
|
- name: Create pull request
|
2024-10-09 12:16:10 +02:00
|
|
|
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
|
2023-04-13 17:44:23 +02:00
|
|
|
with:
|
|
|
|
branch: "image/automated/update-measurements-${{ github.run_number }}"
|
|
|
|
base: main
|
|
|
|
title: "image: update measurements and image version"
|
|
|
|
body: |
|
|
|
|
:robot: *This is an automated PR.* :robot:
|
|
|
|
|
|
|
|
The PR is triggered as part of the scheduled image build on main.
|
|
|
|
It updates the hardcoded measurements and the image version (for QEMU/MiniConstellation).
|
|
|
|
commit-message: "image: update measurements and image version"
|
|
|
|
committer: edgelessci <edgelessci@users.noreply.github.com>
|
2024-06-05 10:41:19 +02:00
|
|
|
author: edgelessci <edgelessci@users.noreply.github.com>
|
2023-04-13 17:44:23 +02:00
|
|
|
labels: no changelog
|
|
|
|
# We need to push changes using a token, otherwise triggers like on:push and on:pull_request won't work.
|
|
|
|
token: ${{ !github.event.pull_request.head.repo.fork && secrets.CI_COMMIT_PUSH_PR || '' }}
|
2023-11-15 08:48:13 +01:00
|
|
|
|
|
|
|
notify-failure:
|
|
|
|
if: failure()
|
|
|
|
needs: [ "stream", "build-image", "update-code" ]
|
2024-10-09 12:16:10 +02:00
|
|
|
runs-on: ubuntu-24.04
|
2023-11-15 08:48:13 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-06-19 15:19:41 +02:00
|
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
2023-11-15 08:48:13 +01:00
|
|
|
with:
|
|
|
|
ref: ${{ github.head_ref }}
|
|
|
|
|
|
|
|
- name: Pick assignee
|
|
|
|
id: pick-assignee
|
|
|
|
continue-on-error: true
|
|
|
|
uses: ./.github/actions/pick_assignee
|
|
|
|
|
|
|
|
- name: Notify failure
|
|
|
|
continue-on-error: true
|
|
|
|
uses: ./.github/actions/notify_teams
|
|
|
|
with:
|
|
|
|
teamsWebhookURI: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
|
|
|
|
title: "Constellation image build failed"
|
|
|
|
assignee: ${{ steps.pick-assignee.outputs.assignee }}
|