Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add github actions to setup automated promotion of charts #284

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/promote_to_prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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: Check for changes
id: check-changes
run: |
if diff -r charts/staging charts/prod > /dev/null; then
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "changes_detected=true" >> $GITHUB_OUTPUT
fi

- name: Promote Changes
if: steps.check-changes.outputs.changes_detected == 'true'
run: |
rm -rf charts/prod
cp -r charts/staging charts/prod

- name: Commit and Create Pull Request
if: steps.check-changes.outputs.changes_detected == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "${{ steps.env-vars.outputs.pr_title }}"
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
branch: "${{ steps.env-vars.outputs.branch_name }}"
delete-branch: true
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.
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."
62 changes: 62 additions & 0 deletions .github/workflows/promote_to_staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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: Check for changes
id: check-changes
run: |
if diff -r charts/dev charts/staging > /dev/null; then
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "changes_detected=true" >> $GITHUB_OUTPUT
fi

- name: Promote Changes
if: steps.check-changes.outputs.changes_detected == 'true'
run: |
rm -rf charts/staging
cp -r charts/dev charts/staging

- name: Commit and Create Pull Request
if: steps.check-changes.outputs.changes_detected == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "${{ steps.env-vars.outputs.pr_title }}"
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
branch: "${{ steps.env-vars.outputs.branch_name }}"
delete-branch: true
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.
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."