Deploy #109
This file contains 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: | |
actions: read | |
contents: read | |
deployments: read | |
packages: read | |
jobs: | |
build: | |
environment: production | |
if: github.event.workflow_run.conclusion == 'success' | |
name: Deploy to k8s | |
runs-on: ubuntu-latest | |
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@v3 | |
with: | |
repository: onerandomusername/kubernetes | |
token: ${{ secrets.REPO_TOKEN }} | |
- name: Install kubectl | |
uses: azure/setup-kubectl@v3.2 | |
with: | |
version: 'latest' | |
- name: Authenticate with Kubernetes | |
uses: azure/k8s-set-context@v3 | |
with: | |
method: kubeconfig | |
kubeconfig: ${{ secrets.KUBECONFIG }} | |
- name: Login to Github Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Deploy to Kubernetes | |
uses: azure/k8s-deploy@v4 | |
with: | |
manifests: | | |
monty/deployment.yaml | |
images: 'ghcr.io/onerandomusername/monty-python:${{ steps.sha_tag.outputs.tag }}' | |
# annotate-namespace: false | |
# strategy: 'none' |