soringumeni1 triggered Release workflow #10
This file contains hidden or 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
| name: Release workflow | |
| run-name: ${{ github.actor }} triggered 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@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 | |
| 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: 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.yaml > version | |
| echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT | |
| - name: Google Auth | |
| id: auth | |
| uses: "google-github-actions/auth@v2" | |
| 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@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 | |
| 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() |