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

[FEATURE]: Nightly clean review apps and images #603

Merged
merged 9 commits into from
Oct 2, 2024
2 changes: 2 additions & 0 deletions .controlplane/controlplane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ apps:
- rails
# match_if_app_name_starts_with is used to identify these "qa" apps.
match_if_app_name_starts_with: true
image_retention_days: 5
stale_app_image_deployed_days: 5 # If the app is older than 5 days, the nightly automations will clean stale apps.
19 changes: 2 additions & 17 deletions .github/actions/deploy-to-control-plane/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,14 @@ inputs:
runs:
using: 'composite'
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.3' # Specify your Ruby version here

- name: Install Control Plane CLI
shell: bash
run: |
sudo npm install -g @controlplane/[email protected]
cpln --version
gem install cpflow -v 4.0.0
cpflow --version
- name: Setup Environment
uses: ./.github/actions/setup-environment

- name: Set Short SHA
id: vars
shell: bash
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

- name: cpln profile
shell: bash
run: |
cpln profile update default

# Caching step
- uses: actions/cache@v2
with:
Expand Down
25 changes: 25 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Control Plane GitHub Action

name: 'Setup Environment'
description: 'Sets up Ruby, installs Control Plane CLI, cpflow gem, and sets up the default profile'

runs:
using: 'composite'
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.3'

- name: Install Control Plane CLI and cpflow gem
shell: bash
run: |
sudo npm install -g @controlplane/[email protected]
cpln --version
gem install cpflow -v 4.0.0
cpflow --version

- name: cpln profile
shell: bash
run: |
cpln profile update default
30 changes: 30 additions & 0 deletions .github/workflows/nightly-remove-stale-review-apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Nightly Remove Stale Review Apps and Images

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

env:
CPLN_ORG: ${{secrets.CPLN_ORG_STAGING}}
CPLN_TOKEN: ${{secrets.CPLN_TOKEN_STAGING}}

jobs:
remove-stale-review-apps:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup-environment

- name: Run cleanup-stale-apps script
run: |
cpflow cleanup-stale-apps -a qa-react-webpack-rails-tutorial -y

- name: Run cleanup-images script
run: |
cpflow cleanup-images -a qa-react-webpack-rails-tutorial -y
Loading