Merge pull request #57 from SN-Koarashi/automated-build-branch #23
This file contains 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: Build Userscript File | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
if: contains(github.event.head_commit.message, 'Automated Build PR') == false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm install | |
- name: Setup GitHub CLI | |
run: | | |
sudo apt-get install gh | |
- name: Configure Git | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- name: Check if automated-build-branch exists and checkout | |
run: | | |
git fetch origin | |
if git show-ref --quiet refs/heads/automated-build-branch; then | |
git checkout automated-build-branch | |
git pull --rebase origin automated-build-branch | |
else | |
git checkout -b automated-build-branch | |
fi | |
- name: Run build script | |
run: node ./build.js | |
- name: Check for changes before committing | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
git add . | |
git commit -m "Automated build commit" | |
git push origin automated-build-branch | |
else | |
echo "No changes to commit" | |
exit 0 | |
fi | |
- name: Create Pull Request | |
run: | | |
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" | |
gh pr create --base master --head automated-build-branch --title "Automated Build PR" --body "This PR is automatically generated by GitHub Actions." |