|
| 1 | +# Build and publish nvim-dev container image |
| 2 | +# Triggered on changes to dot_files/nvim/ or manual dispatch |
| 3 | +# Image published to: ghcr.io/binarypie/nvim-dev:latest |
| 4 | + |
| 5 | +name: Build nvim-dev Image |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + paths: |
| 12 | + - 'dot_files/nvim/Containerfile' |
| 13 | + - '.github/workflows/build-nvim-dev.yml' |
| 14 | + pull_request: |
| 15 | + paths: |
| 16 | + - 'dot_files/nvim/Containerfile' |
| 17 | + - '.github/workflows/build-nvim-dev.yml' |
| 18 | + workflow_dispatch: |
| 19 | + schedule: |
| 20 | + # Rebuild weekly to get updated packages |
| 21 | + - cron: '0 6 * * 0' |
| 22 | + |
| 23 | +env: |
| 24 | + IMAGE_NAME: nvim-dev |
| 25 | + IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} |
| 26 | + |
| 27 | +jobs: |
| 28 | + build: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + permissions: |
| 31 | + contents: read |
| 32 | + packages: write |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Checkout repository |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Set up Docker Buildx |
| 39 | + uses: docker/setup-buildx-action@v3 |
| 40 | + |
| 41 | + - name: Log in to GitHub Container Registry |
| 42 | + if: github.event_name != 'pull_request' |
| 43 | + uses: docker/login-action@v3 |
| 44 | + with: |
| 45 | + registry: ghcr.io |
| 46 | + username: ${{ github.actor }} |
| 47 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + |
| 49 | + - name: Extract metadata |
| 50 | + id: meta |
| 51 | + uses: docker/metadata-action@v5 |
| 52 | + with: |
| 53 | + images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} |
| 54 | + tags: | |
| 55 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} |
| 56 | + type=sha,prefix= |
| 57 | + type=ref,event=pr |
| 58 | +
|
| 59 | + - name: Build and push |
| 60 | + uses: docker/build-push-action@v5 |
| 61 | + with: |
| 62 | + context: dot_files/nvim |
| 63 | + file: dot_files/nvim/Containerfile |
| 64 | + push: ${{ github.event_name != 'pull_request' }} |
| 65 | + tags: ${{ steps.meta.outputs.tags }} |
| 66 | + labels: ${{ steps.meta.outputs.labels }} |
| 67 | + cache-from: type=gha |
| 68 | + cache-to: type=gha,mode=max |
| 69 | + |
| 70 | + - name: Generate build summary |
| 71 | + if: github.event_name != 'pull_request' |
| 72 | + run: | |
| 73 | + echo "## nvim-dev Image Built" >> $GITHUB_STEP_SUMMARY |
| 74 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 75 | + echo "**Image:** \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY |
| 76 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 77 | + echo "### Usage" >> $GITHUB_STEP_SUMMARY |
| 78 | + echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY |
| 79 | + echo "distrobox create --name nvim-dev --image ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY |
| 80 | + echo "distrobox enter nvim-dev" >> $GITHUB_STEP_SUMMARY |
| 81 | + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
0 commit comments