-
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.
will automatically promote setup a PR to promote charts from dev-staging and staging-prod
- Loading branch information
1 parent
8ea7df8
commit 5469528
Showing
2 changed files
with
156 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Promote Staging to Prod | ||
|
||
on: | ||
schedule: | ||
- cron: '0 12 * * 3' # Wednesday at 12pm UTC | ||
workflow_dispatch: | ||
|
||
jobs: | ||
create-promotion-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Set branch and PR names | ||
id: env-vars | ||
run: | | ||
echo "branch_name=staging-to-prod-${{ steps.date.outputs.date }}" >> $GITHUB_OUTPUT | ||
echo "pr_title=Promote Staging to Prod - ${{ steps.date.outputs.date }}" >> $GITHUB_OUTPUT | ||
- name: Create temporary copy for comparison | ||
run: | | ||
mkdir -p temp_compare | ||
cp -r charts/prod temp_compare/ | ||
- name: Copy files | ||
run: | | ||
rm -rf charts/prod | ||
cp -r charts/staging charts/prod | ||
- name: Check for changes | ||
id: check-changes | ||
run: | | ||
if diff -r temp_compare/prod charts/prod > /dev/null; then | ||
echo "changes_detected=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "changes_detected=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create promotion branch | ||
if: steps.check-changes.outputs.changes_detected == 'true' | ||
run: git checkout -b ${{ steps.env-vars.outputs.branch_name }} | ||
|
||
- name: Commit changes | ||
if: steps.check-changes.outputs.changes_detected == 'true' | ||
run: | | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git add charts/prod | ||
git commit -m "${{ steps.env-vars.outputs.pr_title }}" | ||
- name: Push changes | ||
if: steps.check-changes.outputs.changes_detected == 'true' | ||
run: git push origin ${{ steps.env-vars.outputs.branch_name }} | ||
|
||
- name: Create Pull Request | ||
if: steps.check-changes.outputs.changes_detected == 'true' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
title: ${{ steps.env-vars.outputs.pr_title }} | ||
body: | | ||
Automated promotion PR to copy contents from `staging` to `prod`. | ||
This PR was automatically created by the environment promotion workflow. | ||
branch: ${{ steps.env-vars.outputs.branch_name }} | ||
base: main | ||
labels: | | ||
automated | ||
environment-promotion | ||
- name: Log no changes | ||
if: steps.check-changes.outputs.changes_detected == 'false' | ||
run: echo "No changes detected between staging and prod. Skipping PR creation." |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Promote Dev to Staging | ||
|
||
on: | ||
schedule: | ||
- cron: '0 12 * * 2' # Tuesday at 12pm UTC | ||
workflow_dispatch: | ||
|
||
jobs: | ||
create-promotion-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Set branch and PR names | ||
id: env-vars | ||
run: | | ||
echo "branch_name=dev-to-staging-${{ steps.date.outputs.date }}" >> $GITHUB_OUTPUT | ||
echo "pr_title=Promote Dev to Staging - ${{ steps.date.outputs.date }}" >> $GITHUB_OUTPUT | ||
- name: Create temporary copy for comparison | ||
run: | | ||
mkdir -p temp_compare | ||
cp -r charts/staging temp_compare/ | ||
- name: Copy files | ||
run: | | ||
rm -rf charts/staging | ||
cp -r charts/dev charts/staging | ||
- name: Check for changes | ||
id: check-changes | ||
run: | | ||
if diff -r temp_compare/staging charts/staging > /dev/null; then | ||
echo "changes_detected=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "changes_detected=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create promotion branch | ||
if: steps.check-changes.outputs.changes_detected == 'true' | ||
run: git checkout -b ${{ steps.env-vars.outputs.branch_name }} | ||
|
||
- name: Commit changes | ||
if: steps.check-changes.outputs.changes_detected == 'true' | ||
run: | | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git add charts/staging | ||
git commit -m "${{ steps.env-vars.outputs.pr_title }}" | ||
- name: Push changes | ||
if: steps.check-changes.outputs.changes_detected == 'true' | ||
run: git push origin ${{ steps.env-vars.outputs.branch_name }} | ||
|
||
- name: Create Pull Request | ||
if: steps.check-changes.outputs.changes_detected == 'true' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
title: ${{ steps.env-vars.outputs.pr_title }} | ||
body: | | ||
Automated promotion PR to copy contents from `dev` to `staging`. | ||
This PR was automatically created by the environment promotion workflow. | ||
branch: ${{ steps.env-vars.outputs.branch_name }} | ||
base: main | ||
labels: | | ||
automated | ||
environment-promotion | ||
- name: Log no changes | ||
if: steps.check-changes.outputs.changes_detected == 'false' | ||
run: echo "No changes detected between dev and staging. Skipping PR creation." |