|
| 1 | +# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions |
| 2 | +name: Publish Dev Container |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + tags: |
| 9 | + - v* |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + IMAGE_NAME: ${{ github.repository }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-push-image: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Set up QEMU for multi-arch builds |
| 28 | + uses: docker/setup-qemu-action@v3 |
| 29 | + |
| 30 | + - name: Set up Docker Buildx |
| 31 | + id: buildx |
| 32 | + uses: docker/setup-buildx-action@v3 |
| 33 | + |
| 34 | + - name: Log in to the Container registry |
| 35 | + uses: docker/login-action@v3 |
| 36 | + with: |
| 37 | + registry: ${{ env.REGISTRY }} |
| 38 | + username: ${{ github.actor }} |
| 39 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + |
| 41 | + - name: Extract metadata (tags, labels) for Docker |
| 42 | + id: meta |
| 43 | + uses: docker/metadata-action@v5 |
| 44 | + with: |
| 45 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 46 | + |
| 47 | + - name: Build and push Docker image |
| 48 | + uses: docker/build-push-action@v5 |
| 49 | + with: |
| 50 | + builder: ${{ steps.buildx.outputs.name }} |
| 51 | + platforms: linux/amd64,linux/arm64 |
| 52 | + context: ./devcontainer |
| 53 | + file: ./devcontainer/Dockerfile |
| 54 | + push: true |
| 55 | + provenance: false |
| 56 | + tags: ${{ steps.meta.outputs.tags }} |
| 57 | + labels: ${{ steps.meta.outputs.labels }} |
| 58 | + build-args: | |
| 59 | + VERSION=${{ github.sha }} |
0 commit comments