Skip to content

Add workflow to update base images #68

Add workflow to update base images

Add workflow to update base images #68

Workflow file for this run

name: Build images for PR
on:
pull_request:
types:
- opened
- synchronize
- ready_for_review
- reopened
branches:
- main
jobs:
# This job exists so that PRs from outside the main repo are rejected
fail_on_remote:
runs-on: ubuntu-latest
steps:
- name: PR must be from a branch in the azimuth-images repo
run: exit ${{ github.repository == 'stackhpc/azimuth-images' && '0' || '1' }}
# This job exists so that draft PRs see the check as failed
fail_on_draft:
runs-on: ubuntu-latest
steps:
- name: PR must be marked as ready for review before tests will run
run: exit ${{ github.event.pull_request.draft && '1' || '0' }}
read_builds:
needs: [fail_on_remote, fail_on_draft]
runs-on: ubuntu-latest
outputs:
builds: ${{ steps.builds-as-json.outputs.builds }}
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Install script dependencies
run: pip install -r ./requirements.txt
- name: Get builds as JSON
id: builds-as-json
run: ./bin/builds-as-json
build_images:
needs: [read_builds]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.read_builds.outputs.builds) }}
name: ${{ matrix.name }}
steps:
- name: Check out the repository
uses: actions/checkout@v3
with:
submodules: recursive
# We only build images whose dependencies have changed
- name: Check if image should be built
uses: dorny/paths-filter@v2
id: changes
with:
filters: ${{ matrix.path-filters }}
- name: Write OpenStack credentials
run: echo "$CLOUDS_YAML_B64" | base64 -d > ./clouds.yaml
env:
CLOUDS_YAML_B64: ${{ secrets.CLOUDS_YAML_B64 }}
if: ${{ steps.changes.outputs.paths == 'true' }}
- name: Set up Packer environment
run: ./bin/setup
env:
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.changes.outputs.paths == 'true' }}
- name: Build image
run: ./bin/build-image
env:
OS_CLOUD: openstack
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ENVIRONMENT: arcus
PACKER_TEMPLATE: ${{ matrix.template }}
ENV_VAR_FILES: ${{ matrix.var-files }}
# For PRs, we don't need to save images
PKR_VAR_skip_create_image: "true"
if: ${{ steps.changes.outputs.paths == 'true' }}