BlueWallet/.github/workflows/lockfiles_update.yml

97 lines
2.9 KiB
YAML
Raw Normal View History

2024-09-11 13:23:01 -04:00
name: Lock Files Update
2024-09-11 12:35:35 -04:00
2024-09-11 12:22:50 -04:00
on:
2024-09-11 13:47:39 -04:00
workflow_dispatch:
2024-09-11 13:45:25 -04:00
push:
2024-09-11 12:25:25 -04:00
branches:
- master
2024-09-11 12:22:50 -04:00
jobs:
pod-update:
runs-on: macos-15
2024-09-11 12:22:50 -04:00
permissions:
contents: write
steps:
2024-09-11 13:47:39 -04:00
2024-09-11 13:23:01 -04:00
- name: Checkout master branch
2024-09-11 12:22:50 -04:00
uses: actions/checkout@v4
with:
2024-09-11 13:23:01 -04:00
ref: master # Ensures we're checking out the master branch
fetch-depth: 0 # Ensures full history to enable branch deletion and recreation
2024-09-11 12:53:10 -04:00
2024-09-11 13:23:01 -04:00
- name: Delete existing branch
run: |
git push origin --delete pod-update-branch || echo "Branch does not exist, continuing..."
git branch -D pod-update-branch || echo "Local branch does not exist, continuing..."
- name: Create new branch from master
run: git checkout -b pod-update-branch # Create a new branch from the master branch
2024-09-11 12:22:50 -04:00
- name: Specify node version
uses: actions/setup-node@v4
with:
node-version: 20
2024-09-11 12:53:10 -04:00
- name: Install node modules
run: npm install
2024-09-11 13:35:46 -04:00
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.6
bundler-cache: true
- name: Install and update Ruby Gems
run: |
bundle install
2024-09-11 12:22:50 -04:00
- name: Install CocoaPods Dependencies
run: |
cd ios
pod install
pod update
2024-09-11 13:35:46 -04:00
- name: Check for changes
id: check-changes
run: |
git diff --quiet package-lock.json ios/Podfile.lock || echo "Changes detected"
continue-on-error: true
- name: Stop job if no changes
if: steps.check-changes.outcome == 'success'
run: |
echo "No changes detected in package-lock.json or Podfile.lock. Stopping the job."
exit 0
2024-09-11 13:06:29 -04:00
- name: Commit changes
2024-09-11 13:35:46 -04:00
if: steps.check-changes.outcome != 'success'
2024-09-11 12:22:50 -04:00
run: |
2024-09-11 13:23:01 -04:00
git add package-lock.json ios/Podfile.lock
2024-09-11 13:35:46 -04:00
git commit -m "Update lock files"
2024-09-11 13:23:01 -04:00
2024-09-11 13:35:46 -04:00
# Step 10: Get the list of changed files for PR description
2024-09-11 13:23:01 -04:00
- name: Get changed files for PR description
id: get-changes
2024-09-11 13:35:46 -04:00
if: steps.check-changes.outcome != 'success'
2024-09-11 13:23:01 -04:00
run: |
git diff --name-only HEAD^ HEAD > changed_files.txt
echo "CHANGES=$(cat changed_files.txt)" >> $GITHUB_ENV
2024-09-11 13:35:46 -04:00
# Step 11: Push the changes and create the PR using the LockFiles PAT
2024-09-11 13:06:29 -04:00
- name: Push and create PR
2024-09-11 13:35:46 -04:00
if: steps.check-changes.outcome != 'success'
2024-09-11 13:06:29 -04:00
run: |
2024-09-11 12:22:50 -04:00
git push origin pod-update-branch
2024-09-11 13:35:46 -04:00
gh pr create --title "Lock Files Updates" --body "The following lock files were updated:\n\n${{ env.CHANGES }}" --base master
2024-09-11 12:22:50 -04:00
env:
2024-09-11 13:23:01 -04:00
GITHUB_TOKEN: ${{ secrets.LOCKFILES_WORKFLOW }} # Use the LockFiles PAT for PR creation
cleanup:
runs-on: macos-15
2024-09-11 13:23:01 -04:00
if: github.event.pull_request.merged == true || github.event.pull_request.state == 'closed'
needs: pod-update
steps:
2024-09-11 13:47:39 -04:00
2024-09-11 13:23:01 -04:00
- name: Delete branch after PR merge/close
run: |
git push origin --delete pod-update-branch