Build nvim-dev Image #4
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
| # Build and publish nvim-dev container image | |
| # Triggered on changes to dot_files/nvim/ or manual dispatch | |
| # Image published to: ghcr.io/binarypie/nvim-dev:latest | |
| name: Build nvim-dev Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'dot_files/nvim/Containerfile' | |
| - '.github/workflows/build-nvim-dev.yml' | |
| pull_request: | |
| paths: | |
| - 'dot_files/nvim/Containerfile' | |
| - '.github/workflows/build-nvim-dev.yml' | |
| workflow_dispatch: | |
| schedule: | |
| # Rebuild weekly to get updated packages | |
| - cron: '0 6 * * 0' | |
| env: | |
| IMAGE_NAME: nvim-dev | |
| IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest-m | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=sha,prefix= | |
| type=ref,event=pr | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: dot_files/nvim | |
| file: dot_files/nvim/Containerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Generate build summary | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| echo "## nvim-dev Image Built" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Image:** \`${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Usage" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | |
| echo "distrobox create --name nvim-dev --image ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY | |
| echo "distrobox enter nvim-dev" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |