-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
105 additions
and
138 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
name: Build and test image for Azure | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
distrib: | ||
required: true | ||
type: string | ||
techno: | ||
required: true | ||
type: string | ||
product: | ||
required: true | ||
type: string | ||
base-version: | ||
required: true | ||
type: string | ||
keep-os-disk: | ||
required: true | ||
type: string | ||
|
||
env: | ||
RESOURCE_GROUP: packer-snp | ||
|
||
jobs: | ||
packer: | ||
name: Packer build - ${{ inputs.distrib }} - ${{ inputs.techno }} - ${{ inputs.product }} | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
id-token: write | ||
defaults: | ||
run: | ||
working-directory: ./packer | ||
steps: | ||
- name: Az CLI login | ||
uses: azure/login@v2 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDS_JSON }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup packer | ||
uses: hashicorp/setup-packer@main | ||
|
||
- name: Packer build image | ||
env: | ||
CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} | ||
TECHNO: ${{ inputs.techno }} | ||
BASE_IMAGE_VERSION: ${{ inputs.base-version }} | ||
KEEP_OS_DISK: ${{ inputs.keep-os-disk }} | ||
id: env | ||
run: | | ||
set -ex | ||
if [[ ${GITHUB_REF} = *'refs/tags/'* ]]; then | ||
export COSMIAN_VM_VERSION="${{ github.ref_name }}" | ||
export KEEP_OS_DISK="true" | ||
else | ||
export COSMIAN_VM_VERSION="last_build/${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | ||
fi | ||
if [[ $COSMIAN_VM_VERSION = *'last_build'* ]]; then | ||
export AZURE_IMAGE_VERSION="0.0.0" | ||
else | ||
if [ "${{ inputs.product }}" = "cosmian-vm" ]; then | ||
export AZURE_IMAGE_VERSION="$COSMIAN_VM_VERSION" | ||
elif [ "${{ inputs.product }}" = "ai-runner" ]; then | ||
export AZURE_IMAGE_VERSION="$AI_RUNNER_VERSION" | ||
elif [ "${{ inputs.product }}" = "base-image" ]; then | ||
export AZURE_IMAGE_VERSION="$BASE_IMAGE_VERSION" | ||
elif [ "${{ inputs.product }}" = "kms" ]; then | ||
export AZURE_IMAGE_VERSION="$KMS_VERSION" | ||
else | ||
echo "Unexpected product" | ||
exit 1 | ||
fi | ||
fi | ||
bash ../.github/scripts/azure-packer-build.sh "${{ inputs.product }}" "${{ inputs.distrib }}" | ||
# For Azure, create a final VHD from os disk | ||
if [[ ${GITHUB_REF} = *'refs/tags/'* ]]; then | ||
OS_DISK="${{ inputs.product }}-${{ inputs.distrib }}-${{ inputs.techno }}-${AZURE_IMAGE_VERSION}" | ||
sas=$(az disk grant-access --resource-group "$RESOURCE_GROUP" --name "$OS_DISK" --duration-in-seconds 3600 --access-level Read --query accessSas -o tsv) | ||
az storage blob copy start --destination-blob $OS_DISK.vhd --destination-container packer --account-name "$AZURE_STORAGE_ACCOUNT_NAME" --account-key "$AZURE_STORAGE_ACCOUNT_KEY" --source-uri "$sas" | ||
fi |