Merge pull request #28 from UNINETTSigma2/update-rocker442 #716
This file contains hidden or 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
# Build container images according to https://github.com/marketplace/actions/build-and-push-docker-images | |
name: ci | |
#on: [push, pull_request] | |
on: | |
push: | |
branches: | |
- 'master' | |
jobs: | |
matrix: | |
# Generate matrix for linting (essentially locating all Dockerfile directories) | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-dockerfiles.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: set-dockerfiles | |
run: | | |
#echo "::set-output name=matrix::$(./paths_to_dockerfile.sh | jq .)" | |
#echo "::set-output name=matrix::{\"dockerfiles\":[\"./aiidalab/Dockerfile\"]}" | |
#export PATHS_TO_DOCKERFILE=`find -name Dockerfile | jq -R -s 'split("\n")[:-1]'` | |
#echo "::set-output name=matrix::{\"dockerfiles\": $PATHS_TO_DOCKERFILE}" | |
echo "::set-output name=matrix::$(echo {\"dockerfiles\": $(find -name Dockerfile | jq -R -s 'split("\n")[:-1]')})" | |
check-matrix: | |
runs-on: ubuntu-latest | |
needs: matrix | |
# Only run of there are Dockerfiles present | |
#if: "join(fromJSON(needs.matrix.outputs.matrix), '') != ''" | |
strategy: | |
matrix: ${{fromJSON(needs.matrix.outputs.matrix)}} | |
steps: | |
- name: Install json2yaml | |
run: | | |
sudo npm install -g json2yaml | |
- name: Check matrix definition | |
run: | | |
matrix='${{ needs.matrix.outputs.matrix }}' | |
echo $matrix | |
echo $matrix | jq . | |
echo $matrix | json2yaml | |
linter: | |
runs-on: ubuntu-latest | |
needs: matrix | |
strategy: | |
matrix: ${{fromJSON(needs.matrix.outputs.matrix)}} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: hadolint/[email protected] | |
with: | |
dockerfile: ${{ matrix.dockerfiles }} | |
failure-threshold: error | |
build: | |
needs: [linter] | |
# Should consider to use https://github.com/marketplace/actions/build-and-push-docker-images instead, but requires rewrite | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Run build script | |
run: | | |
./free_disk_space.sh | |
./build.sh | |