[PLAT-1079] Fix/vanish cookie #47
Workflow file for this run
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: Create GitHub Release | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| jobs: | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Exit if PR was closed without merging | |
| run: | | |
| if [ ${{ github.event_name }} == 'pull_request' ]; then | |
| if [ ${{ github.event.pull_request.merged }} == 'false' ]; then | |
| echo "This PR was closed without merging. Exiting..." | |
| exit 0 | |
| fi | |
| fi | |
| - name: Checkout code | |
| uses: actions/checkout@v4.2.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Define TAG | |
| run: | | |
| export VERSION=$(cat package.json | jq '.version' | tr -d '"') | |
| echo "TAG=v$VERSION" >> $GITHUB_ENV | |
| - name: Check if tag exists | |
| id: check_tag | |
| uses: actions/github-script@v7.0.1 | |
| with: | |
| result-encoding: string | |
| script: | | |
| const tag = process.env.TAG; | |
| const { owner, repo } = context.repo; | |
| try { | |
| await github.rest.git.getRef({ | |
| owner, | |
| repo, | |
| ref: `tags/${tag}`, | |
| }); | |
| // If the API call doesn't throw an error, the tag exists | |
| return true; | |
| } catch (error) { | |
| // If the API call throws an error, the tag doesn't exist | |
| return false; | |
| } | |
| env: | |
| TAG: ${{ env.TAG }} | |
| - name: Create Release and Tag | |
| uses: actions/github-script@v7.0.1 | |
| with: | |
| result-encoding: string | |
| retries: 3 | |
| script: | | |
| github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: process.env.TAG, | |
| target_commitish: context.sha, | |
| name: process.env.TAG, | |
| generate_release_notes: true | |
| }) |