Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint GitHub Workflows
on:
pull_request:
paths:
- ".github/workflows/**/*.yml"
- ".github/workflows/**/*.yaml"
push:
paths:
- ".github/workflows/**/*.yml"
- ".github/workflows/**/*.yaml"
jobs:
actionlint:
name: actionlint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Lint workflow files
uses: reviewdog/action-actionlint@v1
4 changes: 2 additions & 2 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
ref: main

- name: Google Auth
id: auth
uses: "google-github-actions/auth@v2"
uses: "google-github-actions/auth@v4"
with:
token_format: "access_token"
project_id: "${{ secrets.PROJECT_ID }}"
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/dev_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ jobs:
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v6
with:
ref: dev

- name: Read BASE IMAGE VERSION file
id: getappversion
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> $GITHUB_OUTPUT
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> "$GITHUB_OUTPUT"

- name: Read MEDCAT VERSION
id: getversion
run: |
sed -n 's/^appVersion:\(.*\)/\1/p' < chart/gateway-medcat/Chart.yaml > version
echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart" > "version"
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"

- name: Google Auth
id: auth
uses: "google-github-actions/auth@v2"
uses: "google-github-actions/auth@v4"
with:
token_format: "access_token"
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"

- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
uses: "google-github-actions/setup-gcloud@v2"
with:
version: ">= 363.0.0"

Expand All @@ -54,7 +54,7 @@ jobs:

- name: Login to GAR
id: garlogin
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }}
username: oauth2accesstoken
Expand Down Expand Up @@ -82,13 +82,13 @@ jobs:
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v6
with:
ref: dev

- name: Google Auth
id: auth
uses: "google-github-actions/auth@v0"
uses: "google-github-actions/auth@v4"
with:
token_format: "access_token"
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
Expand All @@ -97,8 +97,8 @@ jobs:
- name: Read MEDCAT VERSION
id: getversion
run: |
sed -n 's/^appVersion:\(.*\)/\1/p' < chart/gateway-medcat/Chart.yaml > version
echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart" > "version"
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"

- name: Deploy to Cloud Run
uses: actions-hub/gcloud@540.0.0
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ jobs:
- name: Check PR Title Format
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_REPO: ${{ github.repository }}
run: |
TITLE="${{ github.event.pull_request.title }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
REPO="${{ github.repository }}"
TITLE="$PR_TITLE"
REPO="$PR_REPO"

echo "PR Title: $TITLE"

Expand Down
90 changes: 15 additions & 75 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run-name: ${{ github.actor }} triggered Release workflow
on:
push:
branches:
- "main"
- "release/*"

env:
PROJECT_ID: "${{ secrets.PROJECT_ID }}"
Expand All @@ -13,101 +13,41 @@ env:
SLACK_CHANNEL: "${{ secrets.GITHUBACTIONS_SLACK_CHANNEL }}"

jobs:
semantic:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
ref: main
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm install

- name: Run Semantic Release
run: npx semantic-release
env:
JIRA_URL: ${{ vars.JIRA_URL }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Set Git config
run: |
git config --local user.email "actions@github.com"
git config --local user.name "Github Actions"

- name: Fetch latest changes from main
run: |
git fetch origin main
git reset --hard origin/main

- name: Merge changes from main to dev
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git fetch origin dev
git checkout dev
git merge --no-ff main || true
git checkout --theirs .
git add .
git commit -m "Auto-resolve merge conflicts by keeping main's changes [skip ci]" || echo "No changes to commit"

git push origin dev

build:
needs: semantic
name: Build and Push Release Image
permissions:
contents: write
id-token: write

runs-on: ubuntu-latest
environment: release
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
ref: main
- name: Checkout repository
uses: actions/checkout@v6

- name: Read BASE IMAGE VERSION file
id: getappversion
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> $GITHUB_OUTPUT

- name: Read MEDCAT VERSION
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> "$GITHUB_OUTPUT"
- name: Extract version from branch
id: getversion
run: |
sed -n 's/^appVersion:\(.*\)/\1/p' < chart/gateway-medcat/Chart.yaml > version
echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT
run: |
branch="${GITHUB_REF_NAME}" # ex: release/1.23.4
version="${branch#release/}" # strip prefix
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Google Auth
id: auth
uses: "google-github-actions/auth@v2"
uses: "google-github-actions/auth@v4"
with:
token_format: "access_token"
project_id: "${{ secrets.PROJECT_ID }}"
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"

- name: "Set up Cloud SDK"
id: setupsdk
uses: "google-github-actions/setup-gcloud@v1"
with:
version: ">= 363.0.0"

- name: "Use gcloud CLI to download the models from google storage bucket"
id: copymodel
run: gsutil -m cp -r '${{ secrets.BUCKET_PATH }}' .

- name: Login to GAR
id: garlogin
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }}
username: oauth2accesstoken
Expand All @@ -133,4 +73,4 @@ jobs:
steps: ${{ toJson(steps) }}
channel: ${{ env.SLACK_CHANNEL }}
message: Running release build on {{ env.GITHUB_REF_NAME }} branch ${{ job.status }}
if: always()
if: always()
136 changes: 136 additions & 0 deletions .github/workflows/semantic-release-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Semantic Release workflow
run-name: ${{ github.actor }} Semantic Release workflow

on:
push:
branches:
- "main"

env:
PROJECT_ID: "${{ secrets.PROJECT_ID }}"
GAR_LOCATION: "${{ secrets.GAR_LOCATION }}"
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL}}"
SLACK_CHANNEL: "${{ secrets.GITHUBACTIONS_SLACK_CHANNEL }}"

jobs:
semantic:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_TOKEN }}
ref: main
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm install

- name: Run Semantic Release
run: npx semantic-release
env:
JIRA_URL: ${{ vars.JIRA_URL }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Set Git config
run: |
git config --local user.email "actions@github.com"
git config --local user.name "Github Actions"

- name: Fetch latest changes from main
run: |
git fetch origin main
git reset --hard origin/main

- name: Merge changes from main to dev
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git fetch origin dev
git checkout dev
git merge --no-ff main || true
git checkout --theirs .
git add .
git commit -m "Auto-resolve merge conflicts by keeping main's changes [skip ci]" || echo "No changes to commit"

git push origin dev

build:
needs: semantic
permissions:
contents: write
id-token: write

runs-on: ubuntu-latest
environment: release
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v6
with:
ref: main

- name: Read BASE IMAGE VERSION file
id: getappversion
run: echo "appversion=$(sed -n 's/^MEDCAT_BASE_IMAGE_VERSION=\(.*\)/\1/p' < medcat_versions.yml)" >> "$GITHUB_OUTPUT"

- name: Read MEDCAT VERSION
id: getversion
run: |
sed -n 's/^appVersion:\(.*\)/\1/p' < "chart/gateway-medcat/Chart" > "version"
echo "version=$(sed 's/.*\"\(.*\)\".*/\1/g' "version")" >> "$GITHUB_OUTPUT"

- name: Google Auth
id: auth
uses: "google-github-actions/auth@v4"
with:
token_format: "access_token"
workload_identity_provider: "${{ secrets.WIF_PROVIDER }}"
service_account: "${{ secrets.WIF_SERVICE_ACCOUNT }}"

- name: "Set up Cloud SDK"
id: setupsdk
uses: "google-github-actions/setup-gcloud@v2"
with:
version: ">= 363.0.0"

- name: "Use gcloud CLI to download the models from google storage bucket"
id: copymodel
run: gsutil -m cp -r '${{ secrets.BUCKET_PATH }}' .

- name: Login to GAR
id: garlogin
uses: docker/login-action@v3
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }}
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}

- name: Build and Push Container
id: build
shell: bash
env:
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
GAR_NAME: ${{ secrets.GAR_NAME }}

run: |-
docker build -t '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:${{ github.sha }} -t '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:latest --build-arg MEDCAT_BASE_IMAGE_VERSION=${{ steps.getappversion.outputs.appversion }} ./
docker push --all-tags '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}

- name: Run Notification
id: runnotificationsent
uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ env.SLACK_CHANNEL }}
message: Running release build on {{ env.GITHUB_REF_NAME }} branch ${{ job.status }}
if: always()