name: Create and publish Docker images on: push: branches: - main - chore/path-filter release: types: - published env: REGISTRY: ghcr.io IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}/kekkai jobs: changes: name: Detect changed files runs-on: ubuntu-latest permissions: pull-requests: read outputs: server: ${{ steps.filter.outputs.server }} chart: ${{ steps.filter.outputs.chart }} CR: ${{ steps.filter.outputs.CR }} web: ${{ steps.filter.outputs.web }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 id: filter with: filters: | server: - 'server/**' chart: - 'chart/**' CR: - 'collect-currency/**' web: - 'web/**' build-and-push-server: needs: changes if: ${{ needs.changes.outputs.server == 'true' }} runs-on: ubuntu-latest permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE_PREFIX }}-server tags: | type=raw,value=latest type=ref,event=branch type=sha - uses: docker/build-push-action@v5 with: file: Dockerfile-server context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 build-and-push-chart: needs: changes if: ${{ needs.changes.outputs.chart == 'true' }} runs-on: ubuntu-latest permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE_PREFIX }}-chart tags: | type=raw,value=latest type=ref,event=branch type=sha - uses: docker/build-push-action@v5 with: file: ./chart/Dockerfile context: ./chart push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 build-and-push-CR: needs: changes if: ${{ needs.changes.outputs.CR == 'true' }} runs-on: ubuntu-latest permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE_PREFIX }}-collect-currency tags: | type=raw,value=latest type=ref,event=branch type=sha - uses: docker/build-push-action@v5 with: file: Dockerfile-collect-currency context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 build-and-push-web: needs: changes if: ${{ needs.changes.outputs.web == 'true' }} runs-on: ubuntu-latest permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE_PREFIX }}-web tags: | type=raw,value=latest type=ref,event=branch type=sha - uses: docker/build-push-action@v5 with: file: Dockerfile-web context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64