|
7 | 7 | pull_request: |
8 | 8 | branches: [ 'master' ] |
9 | 9 |
|
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + packages: write |
| 13 | + |
10 | 14 | jobs: |
11 | 15 | build: |
12 | 16 | runs-on: ubuntu-latest |
@@ -106,3 +110,70 @@ jobs: |
106 | 110 | ../${{ steps.repository.outputs.pathref }}.tar.gz |
107 | 111 | fail_on_unmatched_files: true |
108 | 112 | if: startsWith(github.ref, 'refs/tags/') |
| 113 | + |
| 114 | + - name: Set image names |
| 115 | + id: image_names |
| 116 | + if: startsWith(github.ref, 'refs/tags/') |
| 117 | + run: | |
| 118 | + owner=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]') |
| 119 | + repo=$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]') |
| 120 | + echo "app=ghcr.io/${owner}/${repo}" >> "$GITHUB_OUTPUT" |
| 121 | + echo "stats=ghcr.io/${owner}/${repo}-stats" >> "$GITHUB_OUTPUT" |
| 122 | +
|
| 123 | + - name: Set up Docker Buildx |
| 124 | + if: startsWith(github.ref, 'refs/tags/') |
| 125 | + uses: docker/setup-buildx-action@v3 |
| 126 | + |
| 127 | + - name: Log in to GHCR |
| 128 | + if: startsWith(github.ref, 'refs/tags/') |
| 129 | + uses: docker/login-action@v3 |
| 130 | + with: |
| 131 | + registry: ghcr.io |
| 132 | + username: ${{ github.actor }} |
| 133 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 134 | + |
| 135 | + - name: Docker metadata (app) |
| 136 | + id: meta_app |
| 137 | + if: startsWith(github.ref, 'refs/tags/') |
| 138 | + uses: docker/metadata-action@v5 |
| 139 | + with: |
| 140 | + images: ${{ steps.image_names.outputs.app }} |
| 141 | + tags: | |
| 142 | + type=raw,value=${{ github.ref_name }} |
| 143 | + type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }} |
| 144 | + labels: | |
| 145 | + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} |
| 146 | + org.opencontainers.image.revision=${{ github.sha }} |
| 147 | +
|
| 148 | + - name: Build and push app image |
| 149 | + if: startsWith(github.ref, 'refs/tags/') |
| 150 | + uses: docker/build-push-action@v6 |
| 151 | + with: |
| 152 | + context: . |
| 153 | + file: ./Dockerfile |
| 154 | + push: true |
| 155 | + tags: ${{ steps.meta_app.outputs.tags }} |
| 156 | + labels: ${{ steps.meta_app.outputs.labels }} |
| 157 | + |
| 158 | + - name: Docker metadata (stats) |
| 159 | + id: meta_stats |
| 160 | + if: startsWith(github.ref, 'refs/tags/') |
| 161 | + uses: docker/metadata-action@v5 |
| 162 | + with: |
| 163 | + images: ${{ steps.image_names.outputs.stats }} |
| 164 | + tags: | |
| 165 | + type=raw,value=${{ github.ref_name }} |
| 166 | + type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }} |
| 167 | + labels: | |
| 168 | + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} |
| 169 | + org.opencontainers.image.revision=${{ github.sha }} |
| 170 | +
|
| 171 | + - name: Build and push stats image |
| 172 | + if: startsWith(github.ref, 'refs/tags/') |
| 173 | + uses: docker/build-push-action@v6 |
| 174 | + with: |
| 175 | + context: . |
| 176 | + file: ./Dockerfile.stats |
| 177 | + push: true |
| 178 | + tags: ${{ steps.meta_stats.outputs.tags }} |
| 179 | + labels: ${{ steps.meta_stats.outputs.labels }} |
0 commit comments