Skip to content

build(deps): update patch & minor updates #158

build(deps): update patch & minor updates

build(deps): update patch & minor updates #158

Workflow file for this run

name: Push a tagged PR to staging env
on:
pull_request:
types: [labeled]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ECR_NAME: ${{ secrets.ECR_NAME }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER }}
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE }}
jobs:
push-to-staging:
runs-on: ubuntu-latest
if: ${{ github.event.label.name == 'staging:request' }}
steps:
- uses: actions/checkout@v3
- name: Remove active labels from other PRs
run: |
for number in $(gh pr list --label "staging:active" --json number | jq -r '.[].number'); do
gh pr edit ${number} --remove-label "staging:active"
done
- 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: ${ECR_NAME}:${{ github.sha }}
- name: Update image tag and branch name
run: export IMAGE_TAG=${{ github.sha }} && export BRANCH=staging && cat kubernetes-deploy-staging.tpl | envsubst > kubernetes-deploy-staging.yaml
- name: Authenticate to the cluster
env:
KUBE_CERT: ${{ secrets.KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }}
run: |
echo "${KUBE_CERT}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
kubectl config set-credentials deploy-user --token=${KUBE_TOKEN}
kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${KUBE_NAMESPACE}
kubectl config use-context ${KUBE_CLUSTER}
- name: Apply the updated manifest
run: |
kubectl -n ${KUBE_NAMESPACE} apply -f kubernetes-deploy-staging.yaml
- name: Update PR with success
run: |
gh pr comment $PRNUM --body "🚀 Deploying to [staging environment](https://moj-frontend-staging.apps.live.cloud-platform.service.justice.gov.uk/)"
gh pr edit $PRNUM --remove-label "staging:request"
gh pr edit $PRNUM --add-label "staging:active"
env:
PRNUM: ${{ github.event.number }}