Merge pull request #141 from blooop/feat/default-template-prebuilt-image #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Devcontainer Image | |
| on: | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - ".devcontainer/**" | |
| - ".github/workflows/devcontainer.yml" | |
| pull_request: | |
| branches: ["main"] | |
| paths: | |
| - ".devcontainer/**" | |
| - ".github/workflows/devcontainer.yml" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set image metadata | |
| id: meta | |
| run: | | |
| SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) | |
| DATE=$(date +%Y-%m-%d) | |
| echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" | |
| echo "date=$DATE" >> "$GITHUB_OUTPUT" | |
| - name: Build and push devcontainer image | |
| uses: devcontainers/ci@v0.3 | |
| with: | |
| configFile: .devcontainer/ci/devcontainer.json | |
| imageName: ghcr.io/${{ github.repository }}/devcontainer | |
| imageTag: latest,sha-${{ steps.meta.outputs.short_sha }},${{ steps.meta.outputs.date }} | |
| cacheFrom: ghcr.io/${{ github.repository }}/devcontainer:latest | |
| push: ${{ github.event_name != 'pull_request' && 'always' || 'never' }} |