Update Fork and Create Release #108
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: 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 github-actions@github.com | |
- name: Update fork | |
run: | | |
git remote add upstream https://github.com/gnat/css-scope-inline.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/css-scope-inline/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/css-scope-inline/blob/main/CHANGELOG.md) for details." \ | |
--repo ${{ github.repository }} |