-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
131 additions
and
78 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
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,32 +1,94 @@ | ||
# Control Plane GitHub Action | ||
|
||
name: Deploy Main Branch to Control Plane Staging | ||
name: Deploy to Control Plane Staging | ||
run-name: Deploy Control Plane Staging App | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Uncomment the lines you want actions that will cause the workflow to Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [master] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
branches: | ||
- 'main' | ||
- 'master' | ||
- ${{ github.vars.STAGING_APP_BRANCH }} | ||
workflow_dispatch: | ||
|
||
# Convert the GitHub secret variables to environment variables for use by the Control Plane CLI | ||
env: | ||
CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }} | ||
APP_NAME: ${{ vars.STAGING_APP_NAME }} | ||
CPLN_TOKEN: ${{ secrets.CPLN_TOKEN_STAGING }} | ||
CPLN_ORG: ${{ vars.CPLN_ORG_STAGING }} | ||
STAGING_APP_BRANCH: ${{ vars.STAGING_APP_BRANCH }} | ||
|
||
concurrency: | ||
group: deploy-staging | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
deploy-to-control-plane-staging: | ||
debug: | ||
uses: ./.github/workflows/debug-workflow.yml | ||
with: | ||
debug_enabled: false | ||
|
||
validate-branch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if allowed branch | ||
run: | | ||
if [[ -n "${STAGING_APP_BRANCH}" ]]; then | ||
if [[ "${GITHUB_REF#refs/heads/}" != "${STAGING_APP_BRANCH}" ]]; then | ||
echo "This workflow only runs on configured branch: ${STAGING_APP_BRANCH}" | ||
echo "Current branch: ${GITHUB_REF#refs/heads/}" | ||
exit 1 | ||
fi | ||
elif [[ "${GITHUB_REF}" != "refs/heads/main" && "${GITHUB_REF}" != "refs/heads/master" ]]; then | ||
echo "This workflow only runs on main or master branch (no STAGING_APP_BRANCH configured)" | ||
echo "Current branch: ${GITHUB_REF#refs/heads/}" | ||
exit 1 | ||
fi | ||
build: | ||
needs: validate-branch | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image_tag: ${{ steps.build.outputs.image_tag }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for proper SHA handling | ||
ref: master # Explicitly checkout master branch | ||
fetch-depth: 0 | ||
|
||
- name: Setup Environment | ||
uses: ./.github/actions/setup-environment | ||
with: | ||
token: ${{ secrets.CPLN_TOKEN_STAGING }} | ||
org: ${{ vars.CPLN_ORG_STAGING }} | ||
|
||
- name: Build Docker Image | ||
id: build | ||
uses: ./.github/actions/build-docker-image | ||
with: | ||
app_name: ${{ env.APP_NAME }} | ||
org: ${{ vars.CPLN_ORG_STAGING }} | ||
commit: ${{ github.sha }} | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Environment | ||
uses: ./.github/actions/setup-environment | ||
with: | ||
token: ${{ secrets.CPLN_TOKEN_STAGING }} | ||
org: ${{ vars.CPLN_ORG_STAGING }} | ||
|
||
- uses: ./.github/actions/deploy-to-control-plane | ||
- name: Deploy to Control Plane | ||
uses: ./.github/actions/deploy-to-control-plane | ||
with: | ||
app_name: ${{ vars.STAGING_APP_NAME }} | ||
org: ${{ vars.CPLN_ORG_STAGING }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
wait_timeout: ${{ vars.WAIT_TIMEOUT || 900 }} | ||
cpln_token: ${{ secrets.CPLN_TOKEN_STAGING }} |