-
Notifications
You must be signed in to change notification settings - Fork 384
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
Github Actions separate to two jobs and staging #624
Changes from 3 commits
788e600
ec8ab3f
33ce218
0c5fb50
742e247
7d2f639
8112b7f
c336d22
e25c140
91fa0da
a217452
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 }} | ||||||||||||||||||||||||||||||||
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. Fix branch validation configuration. The Apply this fix: branches:
- 'main'
- 'master'
- - ${{ github.vars.STAGING_APP_BRANCH }}
+ - ${{ vars.STAGING_APP_BRANCH }} 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)12-12: character ' ' is invalid for branch and tag names. ref name cannot contain spaces, ~, ^, :, [, ?, *. see (glob) 12-12: property "vars" is not defined in object type {action: string; action_path: string; action_ref: string; action_repository: string; action_status: string; actor: string; actor_id: string; api_url: string; base_ref: string; env: string; event: object; event_name: string; event_path: string; graphql_url: string; head_ref: string; job: string; job_workflow_sha: string; path: string; ref: string; ref_name: string; ref_protected: string; ref_type: string; repository: string; repository_id: string; repository_owner: string; repository_owner_id: string; repositoryurl: string; retention_days: number; run_attempt: string; run_id: string; run_number: string; secret_source: string; server_url: string; sha: string; token: string; triggering_actor: string; workflow: string; workflow_ref: string; workflow_sha: string; workspace: string} (expression) 12-12: character ' ' is invalid for branch and tag names. ref name cannot contain spaces, ~, ^, :, [, ?, *. see (glob) |
||||||||||||||||||||||||||||||||
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 }} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+68
to
+75
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. Add missing required input for Build Docker Image action. The action requires a Add the missing input: - 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 }}
+ PR_NUMBER: '' # Add appropriate value or make it optional in the action 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)68-68: missing input "PR_NUMBER" which is required by action "Build Docker Image" defined at "./.github/actions/build-docker-image". all required inputs are "PR_NUMBER", "app_name", "commit", "org" (action) |
||||||||||||||||||||||||||||||||
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 }} | ||||||||||||||||||||||||||||||||
Comment on lines
+89
to
+96
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. Add missing required input for Deploy to Control Plane action. The action requires a Add the missing input: - 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 }}
+ pr_number: '' # Add appropriate value or make it optional in the action
🧰 Tools🪛 actionlint (1.7.4)88-88: missing input "pr_number" which is required by action "Deploy to Control Plane" defined at "./.github/actions/deploy-to-control-plane". all required inputs are "app_name", "cpln_token", "github_token", "org", "pr_number" (action) |
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.
Fix missing output value assignment.
The job declares
image_tag
as an output but the value is never set in the build step. This could cause deployment failures.Ensure the build step sets the output:
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.4)
317-317: property "image_tag" is not defined in object type {}
(expression)