Last active
February 16, 2021 06:54
-
-
Save digitalronin/862a8ad93de5f4b4838420437a97f3b2 to your computer and use it in GitHub Desktop.
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: Continuous Deployment | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
env: | |
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }} | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Build | |
run: docker build -t foo . | |
- name: Push to ECR | |
id: ecr | |
uses: jwalton/gh-ecr-push@v1 | |
with: | |
access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }} | |
secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }} | |
region: eu-west-2 | |
local-image: foo | |
image: ${{ secrets.ECR_NAME }}:${{ github.sha }} | |
- name: Update image tag | |
env: | |
ECR_URL: ${{ secrets.ECR_URL }} | |
run: export IMAGE_TAG=${{ github.sha }} && cat kubernetes-deploy.tpl | envsubst > kubernetes-deploy.yaml | |
- name: Authenticate to the cluster | |
env: | |
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }} | |
run: | | |
echo "${{ secrets.KUBE_CERT }}" > ca.crt | |
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://api.${KUBE_CLUSTER} | |
kubectl config set-credentials deploy-user --token=${{ secrets.KUBE_TOKEN }} | |
kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${{ secrets.KUBE_NAMESPACE }} | |
kubectl config use-context ${KUBE_CLUSTER} | |
- name: Apply the updated manifest | |
run: | | |
kubectl -n ${KUBE_NAMESPACE} apply -f kubernetes-deploy.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment