|
8 | 8 |
|
9 | 9 | env: |
10 | 10 | REGISTRY: ghcr.io |
11 | | - IMAGE_NAME: ${{ github.repository }} |
12 | 11 |
|
13 | 12 | jobs: |
14 | 13 | build-container: |
|
18 | 17 | contents: read |
19 | 18 | packages: write |
20 | 19 |
|
| 20 | + env: |
| 21 | + IMAGE_NAME: ${{ github.repository }} |
| 22 | + |
21 | 23 | steps: |
22 | 24 | - name: Checkout repository |
23 | 25 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
|
81 | 83 | env: |
82 | 84 | DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && '0' || '7' }} |
83 | 85 |
|
| 86 | + build-postgres-container: |
| 87 | + if: github.event_name != 'pull_request' |
| 88 | + runs-on: ubuntu-latest |
| 89 | + permissions: |
| 90 | + contents: read |
| 91 | + packages: write |
| 92 | + |
| 93 | + env: |
| 94 | + IMAGE_NAME: ${{ github.repository }}-pgdb |
| 95 | + |
| 96 | + steps: |
| 97 | + - name: Checkout repository |
| 98 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 99 | + |
| 100 | + - name: Log in to the Container registry |
| 101 | + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 |
| 102 | + with: |
| 103 | + registry: ghcr.io |
| 104 | + username: ${{ github.actor }} |
| 105 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + |
| 107 | + - name: Set up Buildx |
| 108 | + id: setup-buildx |
| 109 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 110 | + |
| 111 | + - name: Extract metadata (tags, labels) for Container |
| 112 | + id: meta |
| 113 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 |
| 114 | + with: |
| 115 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 116 | + tags: | |
| 117 | + type=ref,event=branch |
| 118 | + type=semver,pattern={{version}} |
| 119 | +
|
| 120 | + - name: Build and push Docker images |
| 121 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 6.18.0 |
| 122 | + with: |
| 123 | + context: . |
| 124 | + file: internal/server/postgres/infra/Containerfile |
| 125 | + platforms: linux/amd64,linux/arm64 |
| 126 | + push: ${{ github.event_name != 'pull_request' }} |
| 127 | + tags: ${{ steps.meta.outputs.tags }} |
| 128 | + labels: ${{ steps.meta.outputs.labels }} |
| 129 | + cache-from: type=gha |
| 130 | + cache-to: type=gha,mode=max |
| 131 | + env: |
| 132 | + DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && '0' || '7' }} |
| 133 | + |
0 commit comments