constellation/.github/workflows/build-coreos.yml

137 lines
5.8 KiB
YAML
Raw Normal View History

name: Build and Upload CoreOS image
on:
workflow_dispatch:
inputs:
coreOSConfigBranch:
description: "Branch of CoreOS config repo to build from"
default: "main"
required: false
2022-09-12 11:06:11 -04:00
imageVersion:
description: "Semantic version including patch e.g. v<major>.<minor>.<patch> (only used for releases)"
required: false
debug:
description: "Build debug image"
type: boolean
default: false
required: false
jobs:
build-coreos-image:
name: "Build CoreOS using customized COSA"
runs-on: [self-hosted, linux, nested-virt]
permissions:
contents: read
packages: read
env:
SHELL: /bin/bash
steps:
- name: Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
submodules: recursive
token: ${{ secrets.CI_GITHUB_REPOSITORY }}
2022-09-14 09:14:26 -04:00
- name: Install build packages
id: install-packages
uses: ./.github/actions/setup_linux
- name: Setup Go environment
uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f
with:
2022-10-06 13:31:12 -04:00
go-version: "1.19.2"
2022-09-14 09:14:26 -04:00
- name: Build bootstrapper
if: ${{ inputs.debug == false }}
uses: ./.github/actions/build_bootstrapper
with:
outputPath: ${{ github.workspace }}/build/bootstrapper
- name: Build debugd
if: ${{ inputs.debug == true }}
uses: ./.github/actions/build_debugd
with:
outputPath: ${{ github.workspace }}/build/bootstrapper
- name: Build disk-mapper
uses: ./.github/actions/build_disk_mapper
with:
outputPath: ${{ github.workspace }}/build/disk-mapper
- name: Determine version
id: version
uses: ./.github/actions/pseudo_version
- name: Log in to the Container registry
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
2022-09-14 09:14:26 -04:00
- name: Install AzCopy
shell: bash
run: |
wget -q https://aka.ms/downloadazcopy-v10-linux -O azcopy.tar.gz
tar --strip-components 1 -xf azcopy.tar.gz
rm azcopy.tar.gz
echo "$(pwd)" >> $GITHUB_PATH
- name: Login to Azure
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Store GH token to be mounted by cosa
shell: bash
run: echo "machine github.com login api password ${{ secrets.CI_GITHUB_REPOSITORY }}" > /tmp/.netrc
# Make sure to set valid names for GCP and Azure
# Azure
# gallery name may include alphanumeric characters, dots and underscores. Must end and begin with an alphanumeric character
# image definition may include alphanumeric characters, dots, dashes and underscores. Must end and begin with an alphanumeric character
# image version has to be semantic version in the form <uint>.<uint>.<uint> . uint may not be larger than 2,147,483,647
#
# GCP
# image family and image name may include lowercase alphanumeric characters and dashes. Must not end or begin with a dash
- name: Configure input variables
shell: bash
run: |
timestamp=${{ steps.version.outputs.timestamp }}
semver=${{ steps.version.outputs.semanticVersion }}
2022-09-12 11:06:11 -04:00
imageVersion=${{ inputs.imageVersion }}
pseudover=${{ steps.version.outputs.pseudoVersion }}
echo "azureImageName=constellation-${pseudover//./-}" >> $GITHUB_ENV
if [ "${{ startsWith(github.ref, 'refs/heads/release/') && (inputs.debug == false) }}" = true ]
then
2022-09-12 11:06:11 -04:00
echo "gcpImageName=constellation-${imageVersion//./-}" >> $GITHUB_ENV
echo "gcpImageFamily=constellation" >> $GITHUB_ENV
echo "azureGalleryName=Constellation" >> $GITHUB_ENV
echo "azureImageDefinition=constellation" >> $GITHUB_ENV
2022-09-12 11:06:11 -04:00
echo "azureImageVersion=${imageVersion:1}" >> $GITHUB_ENV
elif [ "${{ ((github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/heads/release/')) && (inputs.debug == true) }}" = true ]
then
echo "gcpImageName=constellation-${{ steps.version.outputs.timestamp }}" >> $GITHUB_ENV
echo "gcpImageFamily=constellation-debug-${semver//./-}" >> $GITHUB_ENV
echo "azureGalleryName=Constellation_Debug" >> $GITHUB_ENV
echo "azureImageDefinition=${semver}" >> $GITHUB_ENV
echo "azureImageVersion=${timestamp:0:4}.${timestamp:4:4}.${timestamp:8}" >> $GITHUB_ENV
else
echo "gcpImageName=constellation-${{ steps.version.outputs.timestamp }}" >> $GITHUB_ENV
echo "gcpImageFamily=constellation-${{ steps.version.outputs.branchName }}" >> $GITHUB_ENV
echo "azureGalleryName=Constellation_Testing" >> $GITHUB_ENV
echo "azureImageDefinition=${{ steps.version.outputs.branchName }}" >> $GITHUB_ENV
echo "azureImageVersion=${timestamp:0:4}.${timestamp:4:4}.${timestamp:8}" >> $GITHUB_ENV
fi
- name: Build and Upload
id: build-and-upload
2022-09-02 06:44:51 -04:00
shell: bash
run: |
make cosa-image
make -j$(nproc) CONTAINER_ENGINE=docker NETRC=/tmp/.netrc \
COSA_INIT_BRANCH="${{ inputs.coreOSConfigBranch }}" \
GCP_IMAGE_NAME="${{ env.gcpImageName }}" GCP_IMAGE_FAMILY="${{ env.gcpImageFamily }}" \
AZURE_IMAGE_DEFINITION="${{ env.azureImageDefinition }}" AZURE_IMAGE_VERSION="${{ env.azureImageVersion }}" AZURE_GALLERY_NAME="${{ env.azureGalleryName }}" AZURE_IMAGE_NAME="${{ env.azureImageName }}"\
image-gcp image-azure upload-gcp upload-azure
working-directory: ${{ github.workspace }}/image