|
| 1 | +name: Build and Push Docker Image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, master] |
| 6 | + paths: |
| 7 | + - ".devcontainer/Dockerfile" |
| 8 | + pull_request: |
| 9 | + branches: [main, master] |
| 10 | + paths: |
| 11 | + - ".devcontainer/Dockerfile" |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +env: |
| 15 | + REGISTRY: ghcr.io |
| 16 | + IMAGE_NAME: adobe/swan-dawn-builder |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-and-push: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + packages: write |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Set up Docker Buildx |
| 30 | + uses: docker/setup-buildx-action@v3 |
| 31 | + |
| 32 | + - name: Log in to Container Registry |
| 33 | + uses: docker/login-action@v3 |
| 34 | + with: |
| 35 | + registry: ${{ env.REGISTRY }} |
| 36 | + username: ${{ github.actor }} |
| 37 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + |
| 39 | + - name: Extract metadata |
| 40 | + id: meta |
| 41 | + uses: docker/metadata-action@v5 |
| 42 | + with: |
| 43 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 44 | + tags: | |
| 45 | + type=ref,event=branch |
| 46 | + type=ref,event=pr |
| 47 | + type=sha,prefix={{branch}}- |
| 48 | + type=raw,value=latest,enable={{is_default_branch}} |
| 49 | +
|
| 50 | + - name: Build and push Docker image |
| 51 | + uses: docker/build-push-action@v5 |
| 52 | + with: |
| 53 | + context: . |
| 54 | + file: .devcontainer/Dockerfile |
| 55 | + push: true |
| 56 | + tags: ${{ steps.meta.outputs.tags }} |
| 57 | + labels: ${{ steps.meta.outputs.labels }} |
| 58 | + cache-from: type=gha |
| 59 | + cache-to: type=gha,mode=max |
0 commit comments