mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 11:27:32 +00:00
58 lines
1.9 KiB
YAML
58 lines
1.9 KiB
YAML
name: Rename Migrations
|
|
|
|
on:
|
|
pull_request:
|
|
types: [closed]
|
|
paths:
|
|
- 'backend/src/db/migrations/**'
|
|
|
|
jobs:
|
|
rename:
|
|
runs-on: ubuntu-latest
|
|
if: github.event.pull_request.merged == true
|
|
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get list of newly added files in migration folder
|
|
run: |
|
|
git diff --name-status HEAD^ HEAD backend/src/db/migrations | grep '^A' || true | cut -f2 | xargs -r -n1 basename > added_files.txt
|
|
if [ ! -s added_files.txt ]; then
|
|
echo "No new files added. Skipping"
|
|
exit 0
|
|
fi
|
|
|
|
- name: Script to rename migrations
|
|
run: python .github/resources/rename_migration_files.py
|
|
|
|
- name: Commit and push changes
|
|
run: |
|
|
git config user.name github-actions
|
|
git config user.email [email protected]
|
|
git add ./backend/src/db/migrations
|
|
rm added_files.txt
|
|
git commit -m "chore: renamed new migration files to latest timestamp (gh-action)"
|
|
|
|
- name: Get PR details
|
|
id: pr_details
|
|
run: |
|
|
PR_NUMBER=${{ github.event.pull_request.number }}
|
|
PR_MERGER=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | jq -r '.merged_by.login')
|
|
|
|
echo "PR Number: $PR_NUMBER"
|
|
echo "PR Merger: $PR_MERGER"
|
|
echo "pr_merger=$PR_MERGER" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create Pull Request
|
|
if: env.SKIP_RENAME != 'true'
|
|
uses: peter-evans/create-pull-request@v6
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
commit-message: 'chore: renamed new migration files to latest UTC (gh-action)'
|
|
title: 'GH Action: rename new migration file timestamp'
|
|
branch-suffix: timestamp
|
|
reviewers: ${{ steps.pr_details.outputs.pr_merger }}
|