Skip to content

Check for EKS cluster updates #131

Check for EKS cluster updates

Check for EKS cluster updates #131

name: Check for EKS cluster updates
on:
workflow_dispatch:
schedule:
- cron: "0 13 * * 1" # 1pm Monday UTC
env:
AWS_DEFAULT_REGION: ca-central-1
EKS_CLUSTER_NAME: notification-canada-ca-staging-eks-cluster
jobs:
check-eks-cluster-update:
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Get latest cluster version
id: latest
run: |
LATEST_VERSION="$(aws eks describe-addon-versions \
| jq -r ".addons[] | .addonVersions[] | .compatibilities[] | .clusterVersion" \
| sort -r \
| head -1)"
echo "version=${LATEST_VERSION}" >> "$GITHUB_OUTPUT"
- name: Get Staging cluster version
id: current
run: |
CLUSTER_VERSION="$(aws eks describe-cluster \
--name ${{ env.EKS_CLUSTER_NAME }} \
--query 'cluster.version' --output text)"
echo "version=${CLUSTER_VERSION}" >> "$GITHUB_OUTPUT"
- name: Post to slack
if: steps.latest.outputs.version != steps.current.outputs.version
#checkov:skip=CKV_GHA_3:This is an expected use of curl
run: |
json='{"blocks":[{"type":"section","text":{"type":"mrkdwn","text":":kubernetes: Kubernetes cluster update available: <https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html|${{ steps.latest.outputs.version }}>"}}]}'
curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.NOTIFY_DEV_SLACK_WEBHOOK }}