This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
feat: add matrix #39
Workflow file for this run
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, test, and push Docker Images | ||
on: | ||
schedule: | ||
# Execute at 2am EST every day | ||
- cron: '0 21 * * *' | ||
push: | ||
branches: | ||
- "master" | ||
paths: | ||
- ".github/workflows/*" | ||
- "images/**" | ||
- "!images/*/README.md" | ||
- "tests/**" | ||
- "!tests/README.md" | ||
- "requirements-dev.txt" | ||
pull_request: | ||
paths: | ||
- ".github/workflows/*" | ||
- "images/**" | ||
- "!images/*/README.md" | ||
- "tests/**" | ||
- "!tests/README.md" | ||
- "requirements-dev.txt" | ||
jobs: | ||
vars: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
REGISTRY_NAME: "k8scc01covidacr" | ||
DEV_REGISTRY_NAME: "k8scc01covidacrdev" | ||
branch-name: ${{ steps.getBranch.outputs.branch-name }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get branch name | ||
id: getBranch | ||
run: | | ||
chmod +x ./make_helpers/get_branch_name.sh | ||
BRANCH_NAME=$(./make_helpers/get_branch_name.sh) | ||
echo "branch-name=$BRANCH_NAME" | ||
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT | ||
- name: Set up environment | ||
run: echo "Environment has been set up." | ||
build-docker-images: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
job: ${{ fromJson(steps.load-matrix.outputs.jobMatrix) }} | ||
needs: ${{ matrix.job.parent-job || 'vars' }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Load job matrix from file | ||
id: load-matrix | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const matrix = JSON.parse(fs.readFileSync('images/stages.json', 'utf8')); | ||
return matrix.jobs; | ||
result-encoding: string | ||
result: jobMatrix | ||
- name: Build and Push Docker Images | ||
uses: ./.github/workflows/docker-steps.yaml | ||
with: | ||
image: ${{ matrix.job.image }} | ||
directory: ${{ matrix.job.directory }} | ||
base-image: ${{ matrix.job.base-image || '' }} | ||
parent-image: ${{ matrix.job.parent-job || '' }} | ||
parent-image-is-diff: ${{ matrix.job.parent-job && needs[matrix.job.parent-job].outputs.is-diff || '' }} | ||
registry-name: "${{ needs.vars.outputs.REGISTRY_NAME }}" | ||
branch-name: "${{ needs.vars.outputs.branch-name }}" | ||
is-final: "${{ matrix.job.is-final || 'false' }}" | ||
secrets: | ||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} | ||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | ||
CVE_ALLOWLIST: ${{ secrets.CVE_ALLOWLIST }} |