22 #22
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: Publish | |
on: | |
push: | |
paths: | |
- .github/workflows/* | |
- platforms/*/*/Dockerfile | |
- platforms/*/*/*/Dockerfile | |
- matrix.py | |
- values.yaml | |
- template.py | |
jobs: | |
create_matrix: | |
name: Create Matrix | |
runs-on: ubuntu-22.04 | |
outputs: | |
matrix: ${{ steps.create-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Create list of changed files | |
run: | | |
# See https://github.community/t/check-pushed-file-changes-with-git-diff-tree-in-github-actions/17220/10 | |
if [ $GITHUB_BASE_REF ]; then | |
# Pull Request | |
git fetch origin $GITHUB_BASE_REF --depth=1 | |
export DIFF=$( git diff --name-only origin/$GITHUB_BASE_REF $GITHUB_SHA ) | |
echo "Diff between origin/$GITHUB_BASE_REF and $GITHUB_SHA" | |
else | |
# Push | |
git fetch origin ${{ github.event.before }} --depth=1 | |
export DIFF=$( git diff --name-only ${{ github.event.before }} $GITHUB_SHA ) | |
echo "Diff between ${{ github.event.before }} and $GITHUB_SHA" | |
fi | |
echo "$DIFF" | tee changed_files.txt | |
- name: Create matrix of images to generate | |
id: create-matrix | |
run: | | |
echo "matrix=$(python3 matrix.py)" >> $GITHUB_OUTPUT | |
run_matrix: | |
name: Run Matrix | |
runs-on: ubuntu-22.04 | |
needs: create_matrix | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.create_matrix.outputs.matrix) }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GHCR_PAT }} | |
- name: Build and push to Github registry | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: ghcr.io/mkst/compilers/${{ matrix.image }}:latest | |
file: ${{ matrix.dockerfile }} |