Build Base Images #10
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: Build Base Images | |
| on: | |
| workflow_dispatch: # Manual trigger | |
| schedule: | |
| - cron: "0 0 1,15 * *" # Bi-weekly on the 1st and 15th at midnight UTC | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ghcr.io/${{ github.repository }}-base | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-base-image: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (SHA tag only) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=sha | |
| - name: Build and push base image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./docker/vget-base | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64 | |
| no-cache: true | |
| tag-latest: | |
| needs: build-base-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract SHA tag | |
| id: sha | |
| run: echo "SHA_TAG=sha-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
| - name: Tag image as latest | |
| run: | | |
| SHA_IMAGE="${{ env.IMAGE_NAME }}:${{ steps.sha.outputs.SHA_TAG }}" | |
| LATEST_IMAGE="${{ env.IMAGE_NAME }}:latest" | |
| echo "Pulling SHA tag: $SHA_IMAGE" | |
| docker pull $SHA_IMAGE | |
| echo "Tagging as: $LATEST_IMAGE" | |
| docker tag $SHA_IMAGE $LATEST_IMAGE | |
| echo "Pushing: $LATEST_IMAGE" | |
| docker push $LATEST_IMAGE | |
| - name: Build summary | |
| run: | | |
| echo "Base image built and tagged successfully!" | |
| echo " - SHA tag: ${{ steps.sha.outputs.SHA_TAG }}" | |
| echo " - Latest tag: latest" | |
| echo " - Image: ${{ env.IMAGE_NAME }}" |