Use local registry for final deploy stage #2
Workflow file for this run
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
| on: | ||
| workflow_call: | ||
| inputs: | ||
| artifact: | ||
| required: true | ||
| type: string | ||
| version: | ||
| required: true | ||
| type: string | ||
| secrets: | ||
| KUBECONFIG: | ||
| required: true | ||
| jobs: | ||
| deploy: | ||
| name: Build, push, & deploy | ||
| runs-on: ubuntu-latest | ||
| servicess: | ||
| registry: | ||
| image: registry:2 | ||
| ports: | ||
| - 5000:5000 | ||
| steps: | ||
| - name: Download image artifact | ||
| uses: actions/download-artifact@v5 | ||
| with: | ||
| name: ${{ inputs.artifact }} | ||
| # Load the image to make use of common layers during the final build. | ||
| - name: Load image from archive | ||
| run: docker load -i ${{ inputs.artifact }}.tar | ||
| - 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: ghcr.io | ||
| username: ${{ github.repository_owner }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| # The version script relies on history. Fetch 100 commits to be safe. | ||
| fetch-depth: 100 | ||
| # Build the final production image and push it to GHCR. | ||
| # Tag it with both the short commit SHA and 'latest'. | ||
| - name: Build final image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: true | ||
| cache-from: | | ||
| ghcr.io/python-discord/snekbox-base:latest | ||
| ghcr.io/python-discord/snekbox-venv:latest | ||
| ghcr.io/python-discord/snekbox:latest | ||
| cache-to: type=inline | ||
| load: true | ||
| tags: | | ||
| ghcr.io/python-discord/snekbox:latest | ||
| ghcr.io/python-discord/snekbox:${{ inputs.version }} | ||
| localhost:5000/local/snekbox:${{ inputs.version }} | ||
| - name: Build PyDis final image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile.pydis | ||
| push: true | ||
| cache-from: | | ||
| ghcr.io/python-discord/snekbox:latest-pydis | ||
| build-args: SNEKBOX_IMAGE=localhost:5000/local/snekbox:${{ inputs.version }} | ||
| cache-to: type=inline | ||
| tags: | | ||
| ghcr.io/python-discord/snekbox:latest-pydis | ||
| ghcr.io/python-discord/snekbox:${{ inputs.version }}-pydis | ||
| # Deploy to Kubernetes. | ||
| - name: Install kubectl | ||
| uses: azure/setup-kubectl@v4 | ||
| - name: Authenticate with Kubernetes | ||
| uses: azure/k8s-set-context@v4 | ||
| with: | ||
| method: kubeconfig | ||
| kubeconfig: ${{ secrets.KUBECONFIG }} | ||
| - name: Deploy to Kubernetes | ||
| uses: azure/k8s-deploy@v5 | ||
| with: | ||
| namespace: snekbox | ||
| manifests: deployment.yaml | ||
| images: 'ghcr.io/python-discord/snekbox:${{ inputs.version }}-pydis' | ||
| # Push the base image to GHCR, with an inline cache manifest. | ||
| - name: Push base image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| target: base | ||
| push: true | ||
| cache-from: ghcr.io/python-discord/snekbox-base:latest | ||
| cache-to: type=inline | ||
| tags: | | ||
| ghcr.io/python-discord/snekbox-base:latest | ||
| ghcr.io/python-discord/snekbox-base:${{ inputs.version }} | ||
| # Push the venv image to GHCR, with an inline cache manifest. | ||
| - name: Push venv image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| target: venv | ||
| push: true | ||
| cache-from: | | ||
| ghcr.io/python-discord/snekbox-base:latest | ||
| ghcr.io/python-discord/snekbox-venv:latest | ||
| cache-to: type=inline | ||
| tags: | | ||
| ghcr.io/python-discord/snekbox-venv:latest | ||
| ghcr.io/python-discord/snekbox-venv:${{ inputs.version }} | ||