Skip to content

Update Fork and Create Release #79

Update Fork and Create Release

Update Fork and Create Release #79

Workflow file for this run

name: Update Fork and Create Release
on:
workflow_dispatch:
schedule:
- cron: '15 2 * * *'
permissions:
contents: write
pull-requests: write
jobs:
update-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Update fork
run: |
git remote add upstream https://github.com/gnat/surreal.git
git fetch upstream
git merge upstream/main --no-edit
git push origin main
- name: Get package version
id: package-version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Check if release exists
id: check_release
run: |
release_exists=$(curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/AnswerDotAI/surreal/releases/tags/v${{ steps.package-version.outputs.version }})
if [ $release_exists -eq 200 ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Create Release
if: steps.check_release.outputs.exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.package-version.outputs.version }}
run: |
gh release create v$VERSION \
--title "Release v$VERSION" \
--notes "Release of version $VERSION
Please refer to the [changelog](https://github.com/gnat/surreal/blob/main/CHANGELOG.md) for details." \
--repo ${{ github.repository }}