Merge branch 'master' of github.com:ans-group/docs.ukfast.co.uk #134
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: Build Docker images and deploy to Production | |
on: | |
push: | |
branches: [ master, main ] | |
jobs: | |
build_and_deploy: | |
runs-on: [self-hosted, docs] | |
permissions: | |
packages: write | |
contents: read | |
environment: | |
name: Production | |
url: https://docs.ukfast.co.uk | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push app image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/ans-group/docs-app:${{ github.sha }} | |
build-args: | | |
essvc=elasticsearch | |
- name: Build and push populator image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/ans-group/docs-populator:${{ github.sha }} | |
file: populator/Dockerfile | |
- name: Setup Kustomize | |
uses: imranismail/setup-kustomize@v2 | |
- name: Build Kustomizations | |
working-directory: .ci/kustomize | |
run: | | |
kustomize create --resources overlays/prod | |
kustomize edit set image appImage=ghcr.io/ans-group/docs-app:${{ github.sha }} | |
kustomize edit set image populatorImage=ghcr.io/ans-group/docs-populator:${{ github.sha }} | |
kustomize edit set namespace docs | |
kustomize edit set label 'app.kubernetes.io/instance:prod' | |
kustomize build . > ../../manifest.yaml | |
- name: Setup kubectl | |
uses: azure/[email protected] | |
- name: Create/Update resources in Kubernetes | |
run: | | |
echo -e "${{ secrets.PROD_KUBECONFIG_ANS }}" > kubeconfig.yaml | |
kubectl --kubeconfig kubeconfig.yaml apply -f manifest.yaml |