Skip to content

Commit

Permalink
Made some changes to the GitHub Actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardKanshen committed Nov 10, 2024
1 parent f97932a commit ebebdb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/buildndeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine Workflow Branch
run: echo "TARGET_BRANCH=${{ github.event.pull_request.head.ref || github.ref_name }}" >> $GITHUB_ENV

- name: Switch to Workflow Branch
run: git checkout ${{ env.TARGET_BRANCH }}

- name: Setup Node
uses: actions/setup-node@v4
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/prcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine Workflow Branch
run: echo "TARGET_BRANCH=${{ github.event.pull_request.head.ref || github.ref_name }}" >> $GITHUB_ENV

- name: Switch to Workflow Branch
run: git checkout ${{ env.TARGET_BRANCH }}

- name: Setup Node
uses: actions/setup-node@v4
Expand Down
6 changes: 5 additions & 1 deletion expire-old-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,17 @@ function updateCronSchedule() {

// Step 3: Commit and push changes if any files were modified
function commitAndPushChanges(hasComponentChanges) {
if (process.env.TARGET_BRANCH === undefined) {
console.error('TARGET_BRANCH is not set. Not committing or pushing changes.');
return;
}
try {
if (hasComponentChanges) {
execSync(`git config user.email "41898282+github-actions[bot]@users.noreply.github.com"`);
execSync(`git config user.name "Anti-Social Bot"`);
execSync(`git add .`);
execSync(`git commit -m "Remove expired images and update cron schedule"`);
execSync('git push');
execSync(`git push origin HEAD:${process.env.TARGET_BRANCH}`);
console.log('Changes pushed to repository.');
} else {
console.log('No changes to commit.');
Expand Down

0 comments on commit ebebdb8

Please sign in to comment.