Merge pull request #6 from synapsestudios/fix-tag-name-merge-workflow #2
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: Merge to Main CI | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
create_matrix: | |
uses: ./.github/workflows/create_matrix.yml | |
with: | |
image_directory: "./images" | |
build-and-push: | |
runs-on: ubuntu-latest | |
needs: create_matrix | |
strategy: | |
matrix: | |
image_folder: ${{fromJson(needs.create_matrix.outputs.matrix)}} | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
- name: Set Image Name output | |
run: echo "image_name=$(python3 -c "print('${{ matrix.image_folder }}'.split('/')[-1])")" >> $GITHUB_OUTPUT | |
id: set_image_name | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ matrix.image_folder }}/. | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/${{ steps.set_image_name.outputs.image_name }}:${{ github.sha }} | |
ghcr.io/${{ github.repository_owner }}/${{ steps.set_image_name.outputs.image_name }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |