Feat/build tooling (#71) #11
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: Custom Images CI | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- 'custom-images/**' | |
jobs: | |
find-out-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
changed_directories: ${{ steps.set-output.outputs.changed_directories }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/[email protected] | |
with: | |
dir_names: true | |
json: true | |
quotepath: false | |
dir_names_exclude_current_dir: true | |
files: custom-images/** | |
- name: 'Set output in the matrix format' | |
id: set-output | |
run: echo "changed_directories={\"dir\":${{ steps.changed-files.outputs.all_changed_files }}}" >> "$GITHUB_OUTPUT" | |
build-and-publish: | |
runs-on: ubuntu-latest | |
if: ${{ needs.find-out-changes.outputs.changed_directories != '' }} | |
strategy: | |
matrix: ${{fromJson(needs.find-out-changes.outputs.changed_directories)}} | |
needs: | |
- find-out-changes | |
container: | |
image: aidanhilt/atils-ci:latest | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Check for .atils_buildconfig.json | |
id: check-buildconfig | |
run: | | |
if [ ! -f "${{ matrix.dir }}/.atils_buildconfig.json" ]; then | |
echo "No .atils_buildconfig.json found in ${{ matrix.dir }}. Exiting with failure." | |
exit 1 | |
fi | |
- name: Build and publish custom image | |
if: steps.check-buildconfig.outcome == 'success' | |
run: | | |
atils build --build-directory "${{ matrix.dir }}" --action-set ci-build-publish |