|
| 1 | +name: Build staging Docker image |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +env: |
| 7 | + REGISTRY: ghcr.io |
| 8 | + IMAGE_NAME: ${{ github.repository }} |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-and-push-image: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + packages: write |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + - name: Set up QEMU |
| 21 | + uses: docker/setup-qemu-action@v3 |
| 22 | + - name: Set up Docker Buildx |
| 23 | + uses: docker/setup-buildx-action@v3 |
| 24 | + |
| 25 | + - name: Log in to the Container registry |
| 26 | + uses: docker/login-action@v3 |
| 27 | + with: |
| 28 | + registry: ${{ env.REGISTRY }} |
| 29 | + username: ${{ github.actor }} |
| 30 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + |
| 32 | + - name: Get release metadata |
| 33 | + id: release-meta |
| 34 | + run: | |
| 35 | + version=$(cat package.json | jq -r .version) |
| 36 | + echo "commit_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 37 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 38 | + echo "major_version=$(echo "$version" | cut -d. -f1)" >> $GITHUB_OUTPUT |
| 39 | + - name: Extract metadata (tags, labels) for Docker |
| 40 | + id: meta |
| 41 | + uses: docker/metadata-action@v5 |
| 42 | + with: |
| 43 | + tags: type=raw,value=staging |
| 44 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 45 | + |
| 46 | + - name: Build and push Docker image |
| 47 | + uses: docker/build-push-action@v6 |
| 48 | + with: |
| 49 | + context: . |
| 50 | + platforms: linux/amd64 |
| 51 | + push: true |
| 52 | + tags: ${{ steps.meta.outputs.tags }} |
| 53 | + labels: ${{ steps.meta.outputs.labels }} |
| 54 | + cache-from: type=gha |
| 55 | + cache-to: type=gha,mode=max |
0 commit comments