Merge pull request #127 from MekDrop/ci-fix-autobuild-4 #5
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 dist folder | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: 'autobuild' | |
| cancel-in-progress: true | |
| jobs: | |
| update-dist: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run pack | |
| run: npm run pack | |
| - name: Check changed files | |
| id: changed-files | |
| shell: bash | |
| run: | | |
| CHANGED_FILES=$(git diff --name-only) | |
| if [ -z "$CHANGED_FILES" ]; then | |
| echo "No uncommitted changes detected." | |
| echo "any_changed=false" >> $GITHUB_OUTPUT | |
| echo "all_changed_files=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Uncommitted changes detected: $CHANGED_FILES" | |
| echo "any_changed=true" >> $GITHUB_OUTPUT | |
| echo "all_changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set current date as integer | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| id: date | |
| run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
| - name: Set Branch Name | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| id: set-branch | |
| run: echo "branch_name=autobuild-${{ steps.date.outputs.date }}" >> $GITHUB_OUTPUT | |
| - name: Commit dist/ changes | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "[autobuild] dist update" | |
| branch: ${{ steps.set-branch.outputs.branch_name }} | |
| file_pattern: dist/** | |
| - name: Create Pull Request | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| id: create-pr | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: ${{ steps.set-branch.outputs.branch_name }} | |
| title: "[AUTOBUILD] ${{ steps.date.outputs.date }}" | |
| body: "Auto-generated update to dist/ from latest main push" | |
| base: main | |
| labels: autobuild | |
| - name: Sleep for 30 seconds | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| uses: juliangruber/sleep-action@v2.0.0 | |
| with: | |
| time: 30s | |
| - name: Auto-merge PR | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| uses: pascalgn/automerge-action@v0.15.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| MERGE_LABELS: autobuild | |
| MERGE_METHOD: squash | |
| MERGE_DELETE_BRANCH: "true" | |
| MERGE_COMMIT_MESSAGE: pull-request-title |