-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ci pipeline for staging branch
- Loading branch information
1 parent
d9440ad
commit d30ef21
Showing
2 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Docker (Staging) | ||
on: | ||
push: | ||
branches: [ "331-staging" ] | ||
|
||
jobs: | ||
build: | ||
name: "Build (${{ matrix.component }})" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
component: [frontend, backend] | ||
include: | ||
- component: frontend | ||
dockerfile: production.dockerfile | ||
args: | | ||
"API_URL=https://circlesstagingapi.devsoc.app" | ||
- component: backend | ||
dockerfile: production.dockerfile | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
with: | ||
platforms: arm64 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GH_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ${{ matrix.component }} | ||
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/331-staging' }} | ||
platforms: linux/amd64 | ||
file: ${{ matrix.component }}/${{ matrix.dockerfile }} | ||
build-args: ${{ matrix.args }} | ||
tags: | | ||
ghcr.io/csesoc/circles-staging-${{ matrix.component }}:${{ github.sha }} | ||
ghcr.io/csesoc/circles-staging-${{ matrix.component }}:latest | ||
labels: ${{ steps.meta.outputs.labels }} | ||
deploy: | ||
name: Deploy (CD) | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
concurrency: production | ||
environment: production | ||
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/331-staging' }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: csesoc/deployment | ||
token: ${{ secrets.GH_TOKEN }} | ||
ref: migration | ||
- name: Install yq - portable yaml processor | ||
uses: mikefarah/[email protected] | ||
- name: Update deployment | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: | | ||
git config user.name "CSESoc CD" | ||
git config user.email "[email protected]" | ||
git checkout -b update/circles-staging/${{ github.sha }} | ||
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/circles-staging-frontend:${{ github.sha }}"' projects/circles-staging/deploy-frontend.yml | ||
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/circles-staging-backend:${{ github.sha }}"' projects/circles-staging/deploy-backend.yml | ||
git add . | ||
git commit -m "feat(circles-staging): update images" | ||
git push -u origin update/circles-staging/${{ github.sha }} | ||
gh pr create -B migration --title "feat(circles-staging): update image" --body "Updates the image for the circles staging deployment to commit csesoc/circles-staging@${{ github.sha }}." > URL | ||
gh pr merge $(cat URL) --squash -d |