Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
0346703
feat: initial general and generic chatbot to deploy infrastructure or…
TheRustifyer Dec 24, 2024
da92ce1
feat: workflows folder
TheRustifyer Dec 24, 2024
28553f4
Merge remote-tracking branch 'origin/feature/GH-1-initial-general-wor…
TheRustifyer Dec 24, 2024
f1408d1
Merge remote-tracking branch 'origin/main' into develop
TheRustifyer Dec 24, 2024
dd51b46
ci: updating the ssh-action version
TheRustifyer Dec 24, 2024
4f5edb6
ci: debugging the step 1 of the parse command on step 2
TheRustifyer Dec 24, 2024
f6783c2
ci(fix): should correctly capture both the --environment and --projec…
TheRustifyer Dec 24, 2024
13d8308
ci(local): Adding configuration for ACT to locally run the GH actions
TheRustifyer Dec 25, 2024
3acc818
ci(local): Adding configuration for ACT to locally run the GH actions
TheRustifyer Dec 25, 2024
dc99172
ci: raising the github script version to 7
TheRustifyer Dec 25, 2024
ca75432
fix: wrong JS syntax for checking a non present env var on the cloud …
TheRustifyer Dec 25, 2024
d487c8f
chore(ci): avoiding to override the GITHUB_TOKEN var
TheRustifyer Dec 25, 2024
f957c65
chore(ci): removing manually set permissions
TheRustifyer Dec 25, 2024
b83cd3c
ci: getting org oauth from the zdc's app
TheRustifyer Dec 25, 2024
7518026
ci: adding the new JWT token form the auth app to the run workflow on…
TheRustifyer Dec 25, 2024
3f985a1
ci: better configuration for using the ZDC Auth Oauth app in the clou…
TheRustifyer Dec 25, 2024
e963d01
ci: updating the message with the workflow status after being triggered
TheRustifyer Dec 26, 2024
9618e30
fix: missing 'truthy' boolean comparisons on empty substitutions --force
TheRustifyer Dec 26, 2024
b4be2ef
feat: Introducing a new step on the action to retrieve the running wo…
TheRustifyer Dec 26, 2024
273e419
feat(ci): completed the basic approach to launch a deploy on an artif…
TheRustifyer Dec 26, 2024
447153b
fix(ci): wrong upstream url project
TheRustifyer Dec 26, 2024
71daa3d
ci: refactoring steps with scripts with inlined JS into JS modules
TheRustifyer Dec 26, 2024
149eb67
ci: logging the data that we can pass to the action
TheRustifyer Dec 26, 2024
051a996
ci: workaround for the undefined steps
TheRustifyer Dec 27, 2024
84cdfd9
ci(fix): solving weird action context to JS syntax empty conversions
TheRustifyer Dec 27, 2024
686cacf
ci(refactor): splitting the JS code on the notify-user module to make…
TheRustifyer Dec 27, 2024
588db6d
ci(fix): missing await on createComment fn
TheRustifyer Dec 27, 2024
8652621
ci: converting the new JS script to an ES module. Added local type-sa…
TheRustifyer Dec 27, 2024
66478ac
ci: refactoring common helper functions into their own modules
TheRustifyer Dec 27, 2024
a489b74
ci: refactoring the parse-command step
TheRustifyer Dec 27, 2024
abadcb0
ci: refactoring the update-pr-comment-step from inlined on yml to JS …
TheRustifyer Dec 28, 2024
b5142fb
ci: refactoring the update-pr-comment-step from inlined on yml to JS …
TheRustifyer Dec 28, 2024
3c2483a
ci: minor code fmt and refactors
TheRustifyer Dec 28, 2024
dffea07
ci: core.setFailed on the catch of REST requests
TheRustifyer Dec 28, 2024
92e1125
Merge remote-tracking branch 'origin/develop' into feature/GH-1-initi…
TheRustifyer Dec 28, 2024
6d0d14c
Merge branch 'feature/GH-1-initial-general-workflows-tests' into develop
TheRustifyer Dec 28, 2024
fb0a57c
ci: introducing tests with jest for the actions-scripts. Added a work…
TheRustifyer Dec 28, 2024
149c3fb
ci: changed the name of the job of the action scripts tests
TheRustifyer Dec 28, 2024
c288c84
ci: including the jest tests report on a comment on the active PR
TheRustifyer Dec 28, 2024
0b23e82
ci: refactoring the tests-report step into their own ECMAscript module
TheRustifyer Dec 28, 2024
e46ff3b
ci(debug): logging the context
TheRustifyer Dec 28, 2024
899f6cf
fix: missing interpolation quotes
TheRustifyer Dec 28, 2024
398aa51
ci(fix): resolving the number of the pr on a different prop of the 'c…
TheRustifyer Dec 28, 2024
2473421
ci: stylizing the tests report
TheRustifyer Dec 28, 2024
3165e21
ci: better style on the tests report
TheRustifyer Dec 28, 2024
46b7853
ci: :sparkles: Basic infrastructure deployment workflow added.
gbm25 Jan 5, 2025
4ce4a5a
chore: :art: getting the output of the first job as an input of the s…
gbm25 Jan 5, 2025
6a9999c
fix: wrong workflow abort logic
gbm25 Jan 5, 2025
1534451
fix: wrong uses case with ssh over the deploy action
gbm25 Jan 5, 2025
f4891d4
chore: avoiding the update pr on comment while developing the infra a…
gbm25 Jan 5, 2025
33b21c3
chore(gh-actions): :bug: Tentative fix for workflow outputs
gbm25 Jan 5, 2025
be1e36a
chore: :lock: Update .gitignore
gbm25 Jan 5, 2025
1a5100c
chore: :art: Improve postgres compose.
gbm25 Jan 5, 2025
2844086
feat: Initial SQL data schema and tables creation for testing on our …
TheRustifyer Jan 6, 2025
4093627
feat(gh-actions): :sparkles: Added steps to upload infra to DO
gbm25 Jan 7, 2025
545b459
chore(gh-actions): Added debug step
gbm25 Jan 7, 2025
5ef0df1
feat(gh-actions): :sparkles: Added new output to pass to reusable wor…
gbm25 Jan 7, 2025
3e7ab46
fix(gh-actions): :bug: Fix secret variable name and Uppercase access
gbm25 Jan 7, 2025
09000fc
fix(gh-actions): :bug: Fix infra uppercase variable
gbm25 Jan 7, 2025
b8f412a
chore(gh-actions): :rocket: Update SSH secrets to use organization ones.
gbm25 Jan 7, 2025
5140234
fix(gh-actions): :bug: Fix appleboy/scp-action parameters
gbm25 Jan 7, 2025
745f5e0
fix(gh-actions): :bug: Added checkout
gbm25 Jan 7, 2025
7f73793
chore(gh-actions): Added debug command
gbm25 Jan 7, 2025
8272243
refactor(gh-actions): :art: Moved folder infra to root.
gbm25 Jan 7, 2025
5e5720d
refactor(gh-actions): :recycle: Break actions in smaller ones.
gbm25 Jan 26, 2025
6c32fcb
fix(gh-actions): :bug: Fix workflow name
gbm25 Jan 26, 2025
67e9549
fix(gh-actions): :bug: Added secrets to generate token
gbm25 Jan 26, 2025
42e4025
fix(gh-actions): :bug: Add secrets for generate token
gbm25 Jan 26, 2025
2a9f80f
fix(gh-actions): :bug: Add checkout on notify user
gbm25 Jan 26, 2025
4ea147a
refactor(gh-actions): :recycle: Change id for parse step
gbm25 Jan 26, 2025
f3e58cb
fix(gh-actions): :bug: Add secret inherit
gbm25 Jan 26, 2025
4deaeb6
fix(gh-actions): :bug: Fix infra variable
gbm25 Jan 26, 2025
dc52934
chore(gh-actions): Add debug for variables
gbm25 Jan 26, 2025
0e43d25
chore(gh-actions): Testing needs change
gbm25 Jan 26, 2025
b678fb5
chore(gh-actions): :recycle: Change jobs needs
gbm25 Jan 26, 2025
32820e2
fix(gh-actions): :bug: Fix project variable
gbm25 Jan 26, 2025
60785fa
chore: Normalize deployment workflows names
gbm25 Jan 27, 2025
ddc175a
chore(gh-actions): :ambulance: Tentative change for project deployment
gbm25 Jan 27, 2025
4c93eaa
chore(gh-actions): :ambulance: Tentative changes for project deployment
gbm25 Jan 27, 2025
c87ae08
chore: Tentative changes for token
gbm25 Jan 27, 2025
8fe90f5
chore: Tentative changes for token
gbm25 Jan 27, 2025
51d36ab
chore: Tentative changes for token
gbm25 Jan 27, 2025
7507f29
chore: Tentative changes for token
gbm25 Jan 27, 2025
d7be080
chore: Tentative changes for token
gbm25 Jan 27, 2025
699845f
chore: Encryption and decryption in token
gbm25 Jan 29, 2025
c2d0f69
chore: Encryption and decryption in token
gbm25 Jan 29, 2025
10373e2
fix(gh-actions): :bug: fix secret name
gbm25 Jan 29, 2025
1e2b58a
fix(gh-actions): 🐛 fix secret name
gbm25 Jan 29, 2025
3562cfc
chore: Try to use token in inputs
gbm25 Jan 29, 2025
8ec6920
chore: Tentative change
gbm25 Jan 29, 2025
bde5240
chore: Tentative change
gbm25 Jan 29, 2025
bcacc28
feat(gh-actions): :rocket: Tentative change generate token as composite
gbm25 Jan 30, 2025
16e5191
fix: composite folder and file naming
gbm25 Jan 30, 2025
c807a7c
feat(gh-actions): 🚀 Tentative change generate token as composite
gbm25 Jan 31, 2025
56b09d4
fix: I forgot the secrets inherit parameter. Oops !
gbm25 Jan 31, 2025
53234d6
fix: Remove extra quotes
gbm25 Jan 31, 2025
928bc9c
chore(gh-actions): :construction_worker: Minor changes on job names
gbm25 Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--action-offline-mode
-e .github/workflows/mock_payloads/deploy_act.json
25 changes: 25 additions & 0 deletions .github/actions/generate-token/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Generate GitHub App Token'
description: 'Generates a GitHub App token'
inputs:
app-id:
description: 'GitHub App ID'
required: true
private-key:
description: 'GitHub App Private Key'
required: true

outputs:
token:
description: 'Generated GitHub App Token'
value: ${{ steps.generate-zdc-token.outputs.token }}

runs:
using: "composite"
steps:
- name: Generate GitHub App Token
uses: actions/create-github-app-token@v1
id: generate-zdc-token
with:
app-id: ${{ inputs.app-id }}
private-key: ${{ inputs.private-key }}
owner: ${{ github.repository_owner }}
47 changes: 47 additions & 0 deletions .github/workflows/actions-scripts-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test Action Scripts

on:
pull_request:
paths:
- 'actions_scripts/**' # Run on PRs affecting the actions_scripts folder

jobs:
test-and-coverage-action-scripts:
runs-on: ubuntu-latest

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

# Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '23'

# Install dependencies
- name: Install dependencies
run: npm ci

# Run tests and capture output
- name: Run tests
id: run_tests
run: |
{
echo 'tests_report<<EOF'
npm test 2>&1
echo EOF
} >> "$GITHUB_OUTPUT"

# Post comment on PR
- name: Add JEST results as a PR comment
uses: actions/github-script@v7
with:
script: |
const steps = ${{ toJSON(steps) }};

const { default: testReportOnPrComment } =
await import('${{ github.workspace }}/actions_scripts/tests_report_on_pr_comment.js');

await testReportOnPrComment(github, context, steps);
63 changes: 63 additions & 0 deletions .github/workflows/deploy-chatbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy Chatbot

on:
issue_comment:
types:
- created

jobs:
parse-command:
name: Parse command
runs-on: ubuntu-latest
outputs:
artifact: ${{ steps.parse-deploy-command.outputs.infra }}
environment: ${{ steps.parse-deploy-command.outputs.environment }}
project: ${{ steps.parse-deploy-command.outputs.project }}

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

- name: Parse Deployment Command
uses: actions/github-script@v7
id: parse-deploy-command
with:
script: |
const { default: parseDeployCommand } =
await import(`${{ github.workspace }}/actions_scripts/parse_deployment_command.js`);

parseDeployCommand({ context, core });
- name: Debug Outputs
run: |
echo "Environment: ${{ steps.parse-deploy-command.outputs.environment }}"
echo "Project: ${{ steps.parse-deploy-command.outputs.project }}"
echo "Infra: ${{ steps.parse-deploy-command.outputs.infra }}"

notify-user:
name: Notify user
needs: [parse-command]
uses: zerodaycode/app-summoners-sync/.github/workflows/notify-user.yml@develop
with:
environment: ${{ needs.parse-command.outputs.environment }}
project: ${{ needs.parse-command.outputs.project }}
infra: ${{ needs.parse-command.outputs.artifact }}

deploy-project:
name: Deploy project
needs: [parse-command, notify-user]
if: needs.parse-command.outputs.project != ''
uses: zerodaycode/app-summoners-sync/.github/workflows/deploy-project.yml@develop
with:
project: ${{ needs.parse-command.outputs.project }}
environment: ${{ needs.parse-command.outputs.environment }}
secrets: inherit

deploy-infra:
name: Deploy Infrastructure
needs: [parse-command, notify-user]
if: needs.parse-command.outputs.artifact != ''
uses: zerodaycode/app-summoners-sync/.github/workflows/deploy-infra.yml@develop
with:
artifact: ${{ needs.parse-command.outputs.artifact }}
environment: ${{ needs.parse-command.outputs.environment }}
secrets: inherit
72 changes: 72 additions & 0 deletions .github/workflows/deploy-infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deploy Infrastructure artifact

on:
workflow_call:
inputs:
artifact:
required: true
type: string
environment:
required: true
type: string
jobs:
deploy_infra_artifact:
name: Deploy Infrastructure Artifact
runs-on: ubuntu-latest
steps:
- name: Validate Artifact
id: validate-artifact
run: |
case "${{ inputs.artifact }}" in
postgres|redis)
echo "Valid artifact: ${{ inputs.artifact }}" ;;
*)
echo "Unknown infra: ${{ inputs.artifact }}"
exit 1 ;;
esac
- name: Build compose filename
id: build-compose-filename
run: |
echo "Artifact: ${{ inputs.artifact }}"
echo "Environment: ${{ inputs.environment }}"
filename="${{ inputs.artifact }}-compose-${{ inputs.environment }}.yml"
echo "Generated filename: $filename"
echo "COMPOSE_FILENAME=$filename" >> $GITHUB_ENV

- name: Deploy Specific Infrastructure
id: generate-secret-name
run: |
INFRA_UPPER=$(echo "${{ inputs.artifact }}" | tr 'a-z' 'A-Z')
ENV_UPPER=$(echo "${{ inputs.environment }}" | tr 'a-z' 'A-Z')

secret_name="SS_${INFRA_UPPER}_${ENV_UPPER}"

echo "Generated secret_name: $secret_name"
echo "SECRET_NAME=$secret_name" >> $GITHUB_OUTPUT

- name: Checkout Code
uses: actions/checkout@v4


- name: Transfer Compose File to Server
uses: appleboy/[email protected]
with:
host: ${{ secrets.DO_SSH_HOST_PRE }}
username: ${{ secrets.DO_SSH_USER_PRE }}
key: ${{ secrets.DO_SSH_KEY_PRE }}
source: "infra/docker/${{ env.COMPOSE_FILENAME }}"
target: /opt/summoners-sync/
rm: true

- name: Run docker with env
uses: appleboy/[email protected]
with:
host: ${{ secrets.DO_SSH_HOST_PRE }}
username: ${{ secrets.DO_SSH_USER_PRE }}
key: ${{ secrets.DO_SSH_KEY_PRE }}
script: |
cd /opt/summoners-sync/infra/docker

echo "${{secrets[steps.generate-secret.outputs.SECRET_NAME] }}" > .env
ls -l
docker-compose --env-file .env -f ${{ env.COMPOSE_FILENAME }} up -d
44 changes: 44 additions & 0 deletions .github/workflows/deploy-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy Project

on:
workflow_call:
inputs:
project:
required: true
type: string
environment:
required: true
type: string


jobs:
deploy_project_artifact:
name: Deploy Project Artifact
runs-on: ubuntu-latest
steps:
- name: Generate Token
id: generate-token
uses: zerodaycode/app-summoners-sync/.github/actions/generate-token@develop
with:
app-id: ${{ vars.ZDC_AUTH_APP_ID }}
private-key: ${{ secrets.ZDC_AUTH_PRIVATE_KEY }}

- name: Trigger Deployment Workflow
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const environment = "${{ inputs.environment }}";
const project = "${{ inputs.project }}";
const workflowId = `deploy-${environment}.yml`;

try {
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: project,
workflow_id: workflowId,
ref: 'main', // Adjust this if necessary based on branch/ref logic
});
} catch (error) {
core.setFailed(`Failed to trigger the workflow: ${error.message}`);
}
Loading