feat(ci): allow running manually #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: {} | |
env: | |
VERSION_URL: https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt | |
SOURCE_IMAGE: flatcar_production_qemu_image.img | |
SOURCE_IMAGE_URL: https://stable.release.flatcar-linux.net/amd64-usr/current/flatcar_production_qemu_image.img | |
TARGET_IMAGE: flatcar_production_proxmoxve_image.img | |
# don't waste job slots on superseded code | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install APT dependencies | |
run: | | |
sudo apt update -y | |
sudo apt install -y qemu-utils | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Download Flatcar QEMU image | |
run: curl -fsSL $SOURCE_IMAGE_URL > $SOURCE_IMAGE | |
- name: Download prebuilt Afterburn RPM | |
id: download-afterburn | |
uses: robinraju/[email protected] | |
with: | |
repository: enix/afterburn | |
latest: true | |
fileName: '*.rpm' | |
tarBall: false | |
zipBall: false | |
out-file-path: 'rpms' | |
- name: Extract Afterburn binary from RPM | |
run: | | |
export AFTERBURN_RPM_NAME=$(ls rpms | grep -v debug | grep -v dracut | grep -v rust) | |
rpm2cpio rpms/$AFTERBURN_RPM_NAME | cpio -idmv | |
cp ./usr/bin/afterburn . | |
- name: Build image | |
run: ./scripts/build_image.sh $SOURCE_IMAGE $TARGET_IMAGE | |
- name: Format version name | |
run: | | |
FLATCAR_VERSION=$(curl -fsSL $VERSION_URL | grep FLATCAR_VERSION_ID | cut -d= -f2) | |
echo FLATCAR_VERSION=$FLATCAR_VERSION >> $GITHUB_ENV | |
BUILD_VERSION=$(date +'%Y%m%d.%H%M') | |
echo BUILD_VERSION=$BUILD_VERSION >> $GITHUB_ENV | |
echo VERSION_NAME="v$FLATCAR_VERSION (build $BUILD_VERSION)" >> $GITHUB_ENV | |
echo TAG="v$FLATCAR_VERSION+b$BUILD_VERSION" >> $GITHUB_ENV | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
with: | |
name: ${{ env.VERSION_NAME }} | |
tag: ${{ env.TAG }} | |
artifacts: ${{ env.TARGET_IMAGE }} | |
body: | | |
Flatcar Version: v${{ env.FLATCAR_VERSION }} | |
Build Version: v${{ env.BUILD_VERSION }} | |
Afterburn Build Version: ${{ steps.download-afterburn.outputs.tag_name }} |