maybe fix actions again again #4
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-images | |
on: | |
push: | |
jobs: | |
list: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: set-matrix | |
run: | | |
echo "matrix=$(find images -type f -name 'Dockerfile.*' | awk -F'.' '{print $2}' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT | |
push-ghcr: | |
needs: list | |
name: Build and push image | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
chal: ${{ fromJson(needs.list.outputs.matrix) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Generate variables | |
id: vars | |
run: | | |
echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT | |
- name: Login to ghcr | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Build image | |
run: | | |
docker build \ | |
--tag ghcr.io/${{ github.repository_owner }}/tag-${{ matrix.chal }}:${{ steps.vars.outputs.date }} \ | |
--tag ghcr.io/${{ github.repository_owner }}/tag-${{ matrix.chal }}:latest \ | |
--file images/Dockerfile.${{ matrix.chal }} \ | |
images | |
- name: Push to ghcr | |
run: | | |
docker push ghcr.io/${{ github.repository_owner }}/tag-${{ matrix.chal }}:${{ steps.vars.outputs.date }} | |
docker push ghcr.io/${{ github.repository_owner }}/tag-${{ matrix.chal }}:latest |