basant307/AI_Governance_Project
048
1name: Patch Release2 3on:4 workflow_dispatch:5 inputs:6 branch:7 description: 'Branch to run the action on'8 required: true9 default: 'master'10 11jobs: 12 patch-release:13 runs-on: ubuntu-latest14 timeout-minutes: 1015 environment: prod16 steps:17 - name: Extract branch name18 shell: bash19 id: extract_branch20 run: |21 echo "BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV22 echo "Branch: " $BRANCH23 - name: checkout patch branch24 uses: actions/checkout@v625 with:26 ref: ${{ env.BRANCH }}27 - uses: actions/setup-node@v628 with:29 node-version-file: .nvmrc30 cache: 'npm'31 - name: Install dependencies32 run: npm install33 - name: Install Playwright Browsers34 run: npx playwright install --with-deps35 - name: Run tests36 run : |37 npm test 38 - name: Get new version string39 id: get_new_patch_version40 run: |41 chmod +rx ./.github/workflows/scripts/new-patch-version.sh42 . ./.github/workflows/scripts/new-patch-version.sh43 shell: bash44 - name: See patch branch45 run: echo branch ${{ env.BRANCH }}46 shell: bash47 - name: See new patch version48 run: echo "# version:" ${{ env.VERSION }}49 shell: bash50 - name: checkout master branch51 uses: actions/checkout@v652 with:53 ref: master54 fetch-depth: 055 - name: Set Git Config56 run : |57 # Set git configs58 git config --global user.name "${GITHUB_ACTOR}"59 git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" 60 - name: Update Version on master 61 id: update_backport_version_master62 run: |63 jq --arg ver "${{ env.VERSION }}" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json64 mv /tmp/temp.json ./documentation/versions.json65 66 git add . && git commit -m "Docs: Add ${{ env.VERSION }} to versions.json"67 git push68 - name: checkout unstable branch69 uses: actions/checkout@v670 with:71 ref: unstable72 fetch-depth: 073 - name: Update Version on unstable 74 id: update_backport_version_unstable75 run: |76 jq --arg ver "${{ env.VERSION }}" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json77 mv /tmp/temp.json ./documentation/versions.json78 79 git add . && git commit -m "Docs: Add ${{ env.VERSION }} to versions.json"80 git push81 git checkout ${{ env.BRANCH }}82 - name: Set Git Config83 run : |84 # Set git configs85 git config --global user.name "${GITHUB_ACTOR}"86 git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" 87 - name: Make Release88 id: release89 run: |90 chmod +rx .github/workflows/scripts/pre_release_test.sh91 . .github/workflows/scripts/pre_release_test.sh ${{ env.BRANCH }}92 - name: Archive action failure results93 uses: actions/upload-artifact@v494 if: ${{ failure() && steps.release.conclusion == 'failure' }}95 with:96 name: npm-release--failure-report97 path: /home/runner/.npm/_logs/98 - name: Publish Package to GitHub Releases99 run: |100 curl -L \101 -X POST \102 -H "Accept: application/vnd.github+json" \103 -H "Authorization: Bearer ${{ secrets.MAIN_GH_TOKEN }}" \104 -H "X-GitHub-Api-Version: 2022-11-28" \105 https://api.github.com/repos/${{ github.repository }}/releases \106 -d '{"tag_name":"v${{ env.VERSION }}","target_commitish":"master","name":"v${{ env.VERSION }}","body":"Release version v${{ env.VERSION }}","draft":false,"prerelease":false,"generate_release_notes":false}'107 - name: Deploy to Github Pages ๐108 if: ${{ env.BRANCH == 'master' }}109 uses: JamesIves/github-pages-deploy-action@v4110 with:111 folder: documentation 112 113 npm_publish:114 needs: patch-release115 permissions:116 contents: read117 id-token: write118 uses: ./.github/workflows/npm-publish.yml119 