Skip to content

Merge pull request #24 from cds-snc/renovate/all-patch #115

Merge pull request #24 from cds-snc/renovate/all-patch

Merge pull request #24 from cds-snc/renovate/all-patch #115

Workflow file for this run

name: Build and push to AWS ECR on schedule
on:
push:
branches:
- main
schedule:
- cron: "0 12 * * 3"
workflow_dispatch:
env:
DOCKER_ORG: public.ecr.aws/cds-snc
DOCKER_SLUG: public.ecr.aws/cds-snc/notify-ipv4-geolocate-webservice
KUBECTL_VERSION: '1.25.4'
permissions:
id-token: write
contents: read
jobs:
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
name: Build and push
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -q awscliv2.zip
sudo ./aws/install --update
aws --version
- name: Configure credentials to CDS public ECR using OIDC
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
with:
role-to-assume: arn:aws:iam::283582579564:role/ipv4-geolocate-webservice-apply
role-session-name: Ipv4GeolocateWebserviceGitHubActions
aws-region: "us-east-1"
- name: Login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registry-type: public
- name: Build
run: |
docker build --build-arg LICENSE_KEY=${{ secrets.LICENSE_KEY }} -t $DOCKER_SLUG:`date '+%Y-%m-%d'` -t $DOCKER_SLUG:latest .
- name: Publish
run: |
docker push $DOCKER_SLUG:latest && docker push $DOCKER_SLUG:`date '+%Y-%m-%d'`
- name: Install kubectl
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client
mkdir -p $HOME/.kube
- name: Configure credentials to Notify dev EKS using OIDC
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: arn:aws:iam::800095993820:role/ipv4-geolocate-webservice-apply
role-session-name: Ipv4GeolocateWebserviceGitHubActions
aws-region: "ca-central-1"
- name: Install DEV Kubernetes configuration
run: |
aws eks --region $AWS_REGION update-kubeconfig --name notification-canada-ca-dev-eks-cluster --alias dev --kubeconfig $HOME/.kube/config
kubectl config use-context dev
- name: Restart ipv4 deployment in dev environment
run: |
kubectl rollout restart deployment/ipv4 -n notification-canada-ca
- name: Configure credentials to Notify staging EKS using OIDC
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: arn:aws:iam::239043911459:role/ipv4-geolocate-webservice-apply
role-session-name: Ipv4GeolocateWebserviceGitHubActions
aws-region: "ca-central-1"
- name: Install staging Kubernetes configuration
run: |
aws eks --region $AWS_REGION update-kubeconfig --name notification-canada-ca-staging-eks-cluster --alias staging --kubeconfig $HOME/.kube/config
kubectl config use-context staging
- name: Restart ipv4 deployment in staging environment
run: |
kubectl rollout restart deployment/ipv4 -n notification-canada-ca
- name: Configure credentials to Notify production EKS using OIDC
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: arn:aws:iam::296255494825:role/ipv4-geolocate-webservice-apply
role-session-name: Ipv4GeolocateWebserviceGitHubActions
aws-region: "ca-central-1"
- name: Install production Kubernetes configuration
run: |
aws eks --region $AWS_REGION update-kubeconfig --name notification-canada-ca-production-eks-cluster --alias prod --kubeconfig $HOME/.kube/config
kubectl config use-context prod
- name: Restart ipv4 deployment in production environment
run: |
kubectl rollout restart deployment/ipv4 -n notification-canada-ca