-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent creation of stale branches in s3-sync cronjob (#323)
* make synchronization use one branch * testing * revert testing changes
- Loading branch information
1 parent
99a0cc8
commit 2ea025f
Showing
1 changed file
with
12 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,10 @@ name: S3-synchronization-cronjob | |
|
||
on: | ||
schedule: | ||
- cron: '0 8 * * *' # Everyday at 8am | ||
- cron: '0 8 * * *' # Run every 8am | ||
|
||
env: | ||
SYNC_BRANCH_NAME: 's3-sync-branch-91rf9321' | ||
|
||
jobs: | ||
sync: | ||
|
@@ -12,21 +15,21 @@ jobs: | |
with: | ||
ref: master | ||
token: ${{ secrets.GH_TOKEN }} | ||
- name: Generate random number | ||
id: random | ||
run: echo "::set-output name=value::$(echo $RANDOM)" | ||
- name: Get current date | ||
id: date | ||
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | ||
- name: Create branch | ||
- name: Delete old sync branch if it exists | ||
run: | | ||
git push -d origin ${{ env.SYNC_BRANCH_NAME }} &>/dev/null || true | ||
- name: Create sync branch | ||
uses: peterjgrainger/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
with: | ||
branch: sync-${{ steps.random.outputs.value }} | ||
branch: ${{ env.SYNC_BRANCH_NAME }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: sync-${{ steps.random.outputs.value }} | ||
ref: ${{ env.SYNC_BRANCH_NAME }} | ||
token: ${{ secrets.GH_TOKEN }} | ||
- name: create env file | ||
run: | | ||
|
@@ -49,6 +52,7 @@ jobs: | |
git push | ||
- name: create pull request | ||
run: | | ||
gh pr create -B master -H sync-${{ steps.random.outputs.value }} --title 'Cronjob/Sync docs folder with s3' --body 'Created by Github action' | ||
gh pr create -B master -H ${{ env.SYNC_BRANCH_NAME }} --title 'Cronjob/Sync docs folder with s3' --body 'Created by Github action' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
|