-
Notifications
You must be signed in to change notification settings - Fork 382
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
Test GitHub triggering review app deployments #597
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
2520ae9
WIP
justin808 3243e05
WIP
justin808 e409340
WIP
justin808 ed63ba6
WIP
justin808 cd2e0eb
WIP
justin808 391515c
WIP
justin808 2de8125
WIP
justin808 a3b9d3c
WIP
justin808 5ffc365
provision the appˆ
justin808 84d7b9f
WIP
justin808 1174ee7
WIP
justin808 b3e3677
Updates for deployment
justin808 e57dfd8
Updates for deployment
justin808 3a45bf8
Updates for deployment
justin808 1e70e76
Updates for deployment
justin808 22d168e
Updates for deployment
justin808 3bb050c
Updates for deployment
justin808 0064554
Updates for deployment
justin808 69ce25e
test error handling
justin808 3c2344c
Updates for deployment
justin808 b050d7e
chore: remove error test
rameziophobia 872d2d2
refactor: rename job to deploy-to-control-plane-review
rameziophobia 7aac4ff
feat: trigger deploying to control-plane review on opening a PR
rameziophobia 13fd8e6
feat: change setup_app_templates: from gvc to app
rameziophobia ff07fdd
refactor: delete unneeded code
rameziophobia 885074d
fix: typo
rameziophobia 0decfa7
fix: styling
rameziophobia d66fa38
feat: add a comment on opening PRs as an instruction for deploying re…
rameziophobia 1f119f1
feat: trigger review-app deployment on commenting "/deploy-review-app"
rameziophobia ec4031c
feat: Add Github confirmation comment upon starting to deploy
rameziophobia f883d84
fix: deprecated cpflow option
rameziophobia 28b1eb5
feat: move confirmation comment to first thing in the review app work…
rameziophobia 664248b
feat: get correct checkout ref in issue_comment event
rameziophobia bb7089a
fix: typo
rameziophobia 551545b
fix: coderabbit suggestions
rameziophobia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
@@ -1,8 +1,22 @@ | ||
#!/bin/bash -e | ||
|
||
echo 'Running release_script.sh per controlplane.yml' | ||
|
||
echo 'Run DB migrations' | ||
./bin/rails db:prepare | ||
log() { | ||
echo "[`date +%Y-%m-%d:%H:%M:%S`]: $1" | ||
} | ||
|
||
echo 'Completed release_script.sh per controlplane.yml' | ||
error_exit() { | ||
log "$1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
log 'Running release_script.sh per controlplane.yml' | ||
|
||
if [ -x ./bin/rails ]; then | ||
log 'Run DB migrations' | ||
./bin/rails db:prepare || error_exit "Failed to run DB migrations" | ||
else | ||
error_exit "./bin/rails does not exist or is not executable" | ||
fi | ||
|
||
log 'Completed release_script.sh per controlplane.yml' |
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
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
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,23 @@ | ||
# Org level secrets are used to store sensitive information that is | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK we don't need to set any secrets so this file isn't useful shall we delete? |
||
# shared across multiple apps in the same organization. This is | ||
# useful for storing things like API keys, database credentials, and | ||
# other sensitive information that is shared across multiple apps | ||
# in the same organization. | ||
|
||
# This is how you apply this once (not during CI) | ||
# cpl apply-template secrets -a qa-react-webpack-rails-tutorial --org shakacode-open-source-examples-staging | ||
|
||
kind: secret | ||
name: {{APP_SECRETS}} | ||
type: dictionary | ||
data: | ||
SOME_ENV: "123456" | ||
|
||
--- | ||
|
||
# Policy is needed to allow identities to access secrets | ||
kind: policy | ||
name: {{APP_SECRETS_POLICY}} | ||
targetKind: secret | ||
targetLinks: | ||
- //secret/{{APP_SECRETS}} |
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
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
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ name: Deploy-To-Control-Plane | |
description: 'Deploys both to staging and to review apps' | ||
|
||
inputs: | ||
# The name of the app to deploy | ||
app_name: | ||
description: 'The name of the app to deploy' | ||
required: true | ||
|
@@ -20,25 +19,25 @@ runs: | |
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.2' # Specify your Ruby version here | ||
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: Set Short SHA | ||
id: vars | ||
shell: bash | ||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | ||
|
||
- name: cpflow profile | ||
- name: cpln profile | ||
shell: bash | ||
run: | | ||
cpln profile update default | ||
# cpln profile update default --token ${CPLN_TOKEN} | ||
|
||
# Caching step | ||
- uses: actions/cache@v2 | ||
|
@@ -49,22 +48,24 @@ runs: | |
${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }} | ||
${{ runner.os }}-docker- | ||
|
||
- name: cpflow setup-app | ||
shell: bash | ||
run: | | ||
if ! cpflow exists -a ${{ inputs.app_name }} ; then | ||
cpflow setup-app -a ${{ inputs.app_name }} | ||
fi | ||
# Provision all infrastructure on Control Plane. | ||
# app react-webpack-rails-tutorial will be created per definition in .controlplane/controlplane.yml | ||
- name: cpflow build-image | ||
shell: bash | ||
run: | | ||
cpln image docker-login | ||
# Use BUILDKIT_PROGRESS=plain to get more verbose logging of the build | ||
# BUILDKIT_PROGRESS=plain cpflow build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} | ||
cpflow build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} | ||
# --cache /tmp/.docker-cache | ||
|
||
- name: Run release script | ||
shell: bash | ||
run: | | ||
# Run database migrations (or other release tasks) with the latest image, | ||
# while the app is still running on the previous image. | ||
# This is analogous to the release phase. | ||
cpflow run './.controlplane/release_script.sh' -a ${{ inputs.app_name }} --image latest | ||
|
||
# --cache /tmp/.docker-cache | ||
- name: Deploy to Control Plane | ||
shell: bash | ||
run: | | ||
cpflow deploy-image -a ${{ inputs.app_name }} --org ${{inputs.org}} | ||
echo "Deploying to Control Plane" | ||
cpflow deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{inputs.org}} --verbose |
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,20 @@ | ||
name: Add helper Comment on PR creation | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
jobs: | ||
comment-on-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add GitHub Comment for review app instructions | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: "Hi 👋 To deploy a review app, please comment `/deploy-review-app`" | ||
}) | ||
rameziophobia marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? I don't see any secrets access from app.yml? What am I missing?
If my conclusion is correct, shall we delete the lines from :27 to :31 ?