Deploy #326
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: Deploy | |
| on: | |
| workflow_run: | |
| workflows: ["Lint, Test, Build"] | |
| branches: | |
| - main | |
| types: | |
| - completed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| {} | |
| jobs: | |
| build: | |
| environment: production | |
| if: github.event.workflow_run.conclusion == 'success' | |
| name: Deploy to k8s | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read # used to checkout the repo | |
| packages: read # used to pull the container | |
| steps: | |
| - name: Create SHA Container Tag | |
| id: sha_tag | |
| run: | | |
| tag=$(cut -c 1-7 <<< $GITHUB_SHA) | |
| echo "tag=$tag" >> $GITHUB_OUTPUT | |
| - name: Checkout code | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| repository: onerandomusername/kubernetes | |
| token: ${{ secrets.REPO_TOKEN }} | |
| persist-credentials: false | |
| - name: Install kubectl | |
| uses: azure/setup-kubectl@776406bce94f63e41d621b960d78ee25c8b76ede # v4.0.1 | |
| with: | |
| version: 'latest' | |
| - name: Authenticate with Kubernetes | |
| uses: azure/k8s-set-context@212a19233d93f03eceaac31ae5a1d1acf650b6ef # v4.0.1 | |
| with: | |
| method: kubeconfig | |
| kubeconfig: ${{ secrets.KUBECONFIG }} | |
| - name: Login to Github Container Registry | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Deploy to Kubernetes | |
| uses: azure/k8s-deploy@6f7c489cecd8da05646259d9fa3daae92e095c7b # v5.0.4 | |
| with: | |
| manifests: | | |
| monty/deployment.yaml | |
| images: 'ghcr.io/onerandomusername/monty-python:${{ steps.sha_tag.outputs.tag }}' | |
| # annotate-namespace: false | |
| # strategy: 'none' |