-
Notifications
You must be signed in to change notification settings - Fork 1
ci: add deploy workflow #13
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||||||||||||
| name: Deploy | ||||||||||||||||
|
|
||||||||||||||||
| on: | ||||||||||||||||
| workflow_run: | ||||||||||||||||
| workflows: ["Build"] | ||||||||||||||||
| types: | ||||||||||||||||
| - completed | ||||||||||||||||
|
|
||||||||||||||||
| workflow_dispatch: {} | ||||||||||||||||
|
|
||||||||||||||||
| permissions: | ||||||||||||||||
| id-token: write | ||||||||||||||||
| contents: read | ||||||||||||||||
|
|
||||||||||||||||
| jobs: | ||||||||||||||||
| check-secrets: | ||||||||||||||||
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | ||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||
| outputs: | ||||||||||||||||
| has-secrets: ${{ steps.check.outputs.has-secrets }} | ||||||||||||||||
| steps: | ||||||||||||||||
| - id: check | ||||||||||||||||
| run: | | ||||||||||||||||
| if [ -z "${{ secrets.AWS_ACCESS_KEY_ID }}" ] || \ | ||||||||||||||||
| [ -z "${{ secrets.AWS_SECRET_ACCESS_KEY }}" ] || \ | ||||||||||||||||
| [ -z "${{ secrets.AWS_ROLE_TO_ASSUME }}" ] || \ | ||||||||||||||||
| [ -z "${{ secrets.AWS_ROLE_SESSION_NAME }}" ] || \ | ||||||||||||||||
| [ -z "${{ secrets.AWS_EKS_CLUSTER_NAME }}" ] || \ | ||||||||||||||||
| [ -z "${{ secrets.AWS_EKS_DEPLOYMENT_NAME }}" ] || \ | ||||||||||||||||
| [ -z "${{ secrets.AWS_EKS_NAMESPACE }}" ]; then | ||||||||||||||||
| echo "has-secrets=false" >> "$GITHUB_OUTPUT" | ||||||||||||||||
| echo "::warning::One or more required secrets are missing. Skipping deploy." | ||||||||||||||||
| else | ||||||||||||||||
| echo "has-secrets=true" >> "$GITHUB_OUTPUT" | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| deploy: | ||||||||||||||||
| needs: check-secrets | ||||||||||||||||
| if: ${{ needs.check-secrets.outputs.has-secrets == 'true' }} | ||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||
|
|
||||||||||||||||
| steps: | ||||||||||||||||
| - uses: aws-actions/configure-aws-credentials@v4 | ||||||||||||||||
| with: | ||||||||||||||||
| aws-region: us-west-2 | ||||||||||||||||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||||||||||||||||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||||||||||||||||
| role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | ||||||||||||||||
| role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }} | ||||||||||||||||
|
Comment on lines
+24
to
+27
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. 🧩 Analysis chain🌐 Web query:
💡 Result: When using aws-actions/configure-aws-credentials@v4 with role-to-assume set and OIDC enabled via permissions: id-token: write in the workflow, the recommended authentication mode is GitHub OIDC. This uses core.getIDToken to obtain a JWT token for assuming the role via sts:AssumeRoleWithWebIdentity, providing short-lived temporary credentials without needing static access keys. Providing static access keys (aws-access-key-id and aws-secret-access-key) is not advised in this setup. The official documentation marks GitHub OIDC as the "[✅ Recommended]" method, explicitly states "Use temporary credentials when possible. OIDC is recommended because it provides temporary credentials," and lists static credentials as an alternative for other scenarios. The action prioritizes OIDC when id-token: write is permitted and role-to-assume is provided, without requiring static keys. Static keys are only for cases like assuming roles without OIDC (e.g., cross-account with existing creds). Citations:
Remove static AWS keys when using OIDC role assumption. Lines 24–25 provide static credentials (aws-access-key-id and aws-secret-access-key) while line 26 configures role-to-assume. With id-token: write enabled, AWS recommends OIDC-only authentication. Static keys in this setup are unnecessary and weaken security posture by introducing long-lived credentials that contradict temporary OIDC credentials. Suggested fix - uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
- aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
- aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
role-duration-seconds: 1200📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| role-duration-seconds: 1200 | ||||||||||||||||
|
|
||||||||||||||||
| - name: Setup kubeconfig | ||||||||||||||||
| shell: bash | ||||||||||||||||
| run: aws eks update-kubeconfig --name ${{ secrets.AWS_EKS_CLUSTER_NAME }} --region us-west-2 | ||||||||||||||||
|
|
||||||||||||||||
| - name: Update Kubernetes Docs deployment | ||||||||||||||||
| run: | | ||||||||||||||||
| kubectl set image ${{ secrets.AWS_EKS_DEPLOYMENT_NAME }} main=ghcr.io/txpipe/docs:${{ github.sha }} --namespace=${{ secrets.AWS_EKS_NAMESPACE }} | ||||||||||||||||
|
Comment on lines
+34
to
+36
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. 🧩 Analysis chain🌐 Web query:
💡 Result: kubectl set image does not wait for rollout completion by default. It updates the image in the Deployment spec, triggering a rolling update by the Deployment controller, but the command returns immediately after patching the API server. To wait for rollout completion and fail on unsuccessful deployment (e.g., in CI), kubectl rollout status is required, as it watches until all new replicas are updated, available (passing readiness probes), and old replicas are scaled down, exiting with non-zero code on timeout or failure. Citations:
Add
Suggested fix - name: Update Kubernetes Docs deployment
run: |
kubectl set image ${{ secrets.AWS_EKS_DEPLOYMENT_NAME }} main=ghcr.io/txpipe/docs:${{ github.sha }} --namespace=${{ secrets.AWS_EKS_NAMESPACE }}
+ kubectl rollout status deployment/${{ secrets.AWS_EKS_DEPLOYMENT_NAME }} --namespace=${{ secrets.AWS_EKS_NAMESPACE }} --timeout=300s📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsThere 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. 🧩 Analysis chain🌐 Web query:
💡 Result: In GitHub Actions for a workflow_run event, github.sha (which corresponds to the GITHUB_SHA environment variable) is empty or unset, as indicated by the official documentation table in "Events that trigger workflows" where the GITHUB_SHA column for workflow_run is blank (unlike events like push or pull_request which have specific SHA values). This means the commit SHA that triggered the current workflow run is not available in github.sha. To target the commit SHA of the triggering (child) workflow run, use github.event.workflow_run.head_sha. This is confirmed by community usage (e.g., Stack Overflow examples) and aligns with the workflow_run webhook payload structure, where event.workflow_run.head_sha provides the head commit SHA of the completed workflow run that triggered the current one. Official docs link to the webhook payload, and the REST API for workflow runs shows head_sha as the relevant field. Citations:
🏁 Script executed: # Check deploy.yml structure and trigger
cat .github/workflows/deploy.ymlRepository: txpipe/docs Length of output: 2069 🏁 Script executed: # Check build.yml for reference
cat .github/workflows/build.ymlRepository: txpipe/docs Length of output: 925 Use Line 36 uses Suggested fixjobs:
deploy:
+ env:
+ IMAGE_TAG: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
@@
steps:
- name: Update Kubernetes Docs deployment
run: |
- kubectl set image ${{ secrets.AWS_EKS_DEPLOYMENT_NAME }} main=ghcr.io/txpipe/docs:${{ github.sha }} --namespace=${{ secrets.AWS_EKS_NAMESPACE }}
+ kubectl set image ${{ secrets.AWS_EKS_DEPLOYMENT_NAME }} main=ghcr.io/txpipe/docs:${IMAGE_TAG} --namespace=${{ secrets.AWS_EKS_NAMESPACE }}🤖 Prompt for AI Agents |
||||||||||||||||
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.
🧩 Analysis chain
🌐 Web query:
For GitHub Actionsworkflow_run, does the trigger include runs from all branches unlessbranchesis explicitly set?💡 Result:
Yes, the GitHub Actions workflow_run trigger includes runs from all branches unless the branches or branches-ignore filter is explicitly set. Official documentation shows basic examples without branch filters, such as: on: workflow_run: workflows: [Build] types: [completed] This configuration triggers on completions of the "Build" workflow regardless of branch. When limiting is needed, docs explicitly state: "You can use the branches or branches-ignore filter to specify what branches the triggering workflow must run on in order to trigger your workflow." The filter is optional for restriction; without it, all branches trigger the workflow.
Citations:
Restrict
workflow_rundeploys tomainto avoid unintended environment updates.Without an explicit
branchesfilter,workflow_runtriggers on all branches. This means feature/PR branch artifacts can deploy to production if their Build succeeds.Suggested fix
on: workflow_run: workflows: ["Build"] types: - completed + branches: + - main @@ jobs: deploy: - if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} + if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') }}🤖 Prompt for AI Agents