Skip to content

Merge remote-tracking branch 'origin/main' into dev #8

Merge remote-tracking branch 'origin/main' into dev

Merge remote-tracking branch 'origin/main' into dev #8

name: Build and Push dev Branch images to Dev (Admin)
on:
workflow_dispatch:
push:
branches:
- dev
env:
AWS_DEFAULT_REGION: ca-central-1
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
name: Build ${{ matrix.target }} image
strategy:
fail-fast: false
matrix:
target: ["k8s"]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: dev
- name: Set image parameters
id: img
run: |
echo "image=admin" >> "$GITHUB_OUTPUT"
echo "dockerfile=ci/Dockerfile" >> "$GITHUB_OUTPUT"
- name: Build container image
run: |
docker build \
--build-arg GIT_SHA=${GITHUB_SHA::7} \
-t ${{ steps.img.outputs.image }}:${GITHUB_SHA::7} \
-f ${{ steps.img.outputs.dockerfile }} \
.
- name: Save image as tarball
run: |
docker save ${{ steps.img.outputs.image }}:${GITHUB_SHA::7} \
-o /tmp/${{ steps.img.outputs.image }}.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.img.outputs.image }}-image
path: /tmp/${{ steps.img.outputs.image }}.tar
retention-days: 1
push-k8s-dev:
name: Push K8s image to Dev ECR
needs: build
uses: ./.github/workflows/reusable_push_ecr.yml
with:
image-name: admin
image-tag-sha: ${{ github.sha }}
aws-region: ca-central-1
branch-name: ${{ github.ref_name }}
env-name: dev
secrets:
account-id: ${{ secrets.DEV_AWS_ACCOUNT_ID }}
update-manifest:
name: Update Manifests Dev Image Tag
needs: [push-k8s-dev]
runs-on: ubuntu-latest
steps:
- name: Update Dev Image Tag in Manifests Repo
run: |
set -e
response=$(curl -s -w "\n%{http_code}" -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.MANIFESTS_WORKFLOW_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/cds-snc/notification-manifests/dispatches \
-d '{
"event_type": "update-docker-image-dev",
"client_payload": {
"component": "ADMIN",
"docker_tag": "'"${GITHUB_SHA::7}"'"
}
}')
body=$(echo "$response" | sed '$d')
status=$(echo "$response" | tail -n1)
echo "GitHub API response status: $status"
echo "GitHub API response body: $body"
if [ "$status" -lt 200 ] || [ "$status" -ge 300 ]; then
echo "Failed to trigger update-docker-image workflow (status $status)"
exit 1
fi
echo "Triggered update-docker-image-dev workflow in notification-manifests repo"