|
| 1 | +name: Publish GHCR Images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - ".github/workflows/publish-ghcr-images.yml" |
| 9 | + - "platform/kratix/promises/redis/pipeline/**" |
| 10 | + - "platform/kratix/promises/runtime-workload/pipeline/**" |
| 11 | + - "platform/demo/provider/todos-api/**" |
| 12 | + - "go/apps/request-logger-http/**" |
| 13 | + - "go/runtimeconditions/**" |
| 14 | + - "go/go.mod" |
| 15 | + - "go/go.sum" |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + publish: |
| 24 | + name: Publish ${{ matrix.image.name }} |
| 25 | + runs-on: ubuntu-latest |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + matrix: |
| 29 | + image: |
| 30 | + - name: redis-pipeline |
| 31 | + context: platform/kratix/promises/redis/pipeline |
| 32 | + file: platform/kratix/promises/redis/pipeline/Dockerfile |
| 33 | + - name: runtime-workload-pipeline |
| 34 | + context: platform/kratix/promises/runtime-workload/pipeline |
| 35 | + file: platform/kratix/promises/runtime-workload/pipeline/Dockerfile |
| 36 | + - name: todos-api |
| 37 | + context: platform/demo/provider/todos-api |
| 38 | + file: platform/demo/provider/todos-api/Dockerfile |
| 39 | + - name: request-logger |
| 40 | + context: go |
| 41 | + file: go/apps/request-logger-http/Dockerfile |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Check out source |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Resolve image name |
| 48 | + id: image |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + owner="$(printf '%s' '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" |
| 52 | + repo="$(printf '%s' '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" |
| 53 | + echo "name=ghcr.io/${owner}/${repo}-${{ matrix.image.name }}" >>"${GITHUB_OUTPUT}" |
| 54 | +
|
| 55 | + - name: Log in to GHCR |
| 56 | + uses: docker/login-action@v3 |
| 57 | + with: |
| 58 | + registry: ghcr.io |
| 59 | + username: ${{ github.actor }} |
| 60 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + |
| 62 | + - name: Generate image metadata |
| 63 | + id: metadata |
| 64 | + uses: docker/metadata-action@v5 |
| 65 | + with: |
| 66 | + images: ${{ steps.image.outputs.name }} |
| 67 | + tags: | |
| 68 | + type=ref,event=branch |
| 69 | + type=sha,prefix=sha- |
| 70 | + type=raw,value=latest,enable={{is_default_branch}} |
| 71 | +
|
| 72 | + - name: Build and push image |
| 73 | + uses: docker/build-push-action@v6 |
| 74 | + with: |
| 75 | + context: ${{ matrix.image.context }} |
| 76 | + file: ${{ matrix.image.file }} |
| 77 | + platforms: linux/amd64 |
| 78 | + push: true |
| 79 | + tags: ${{ steps.metadata.outputs.tags }} |
| 80 | + labels: ${{ steps.metadata.outputs.labels }} |
0 commit comments