-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
fff3efd
commit a4c7dcc
Showing
3 changed files
with
185 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: "π Deploy submodule" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ami-image-id: | ||
required: false | ||
type: string | ||
instance-type: | ||
required: true | ||
type: string | ||
folder: | ||
required: true | ||
type: string | ||
pr-sha: | ||
required: true | ||
type: string | ||
ref: | ||
required: true | ||
type: string | ||
stage-override: | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
start-runner: | ||
name: "π§ Start EC2 runner" | ||
runs-on: ubuntu-latest | ||
outputs: | ||
label: ${{ steps.start-ec2-runner.outputs.label }} | ||
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} | ||
steps: | ||
- name: "π₯ Configure AWS Credentials" | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::262732185023:role/github-action-deploy-role | ||
aws-region: eu-west-1 | ||
retry-max-attempts: 5 | ||
- name: "π Start EC2 runner" | ||
id: start-ec2-runner | ||
uses: machulav/ec2-github-runner@v2 | ||
env: | ||
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
with: | ||
mode: start | ||
github-token: ${{ env.GH_PERSONAL_ACCESS_TOKEN }} | ||
ec2-image-id: ${{ inputs.ami-image-id || 'ami-034dddee671b5c88b' }} | ||
ec2-instance-type: ${{ inputs.instance-type }} | ||
subnet-id: subnet-008e0d55cc46af9a2 | ||
security-group-id: sg-07012408d5797f987 | ||
runner-home-dir: "/home/ubuntu/action-runner-2.311.0" | ||
|
||
deploy-module: | ||
needs: start-runner | ||
uses: ./.github/workflows/deploy-submodule.yml | ||
with: | ||
runner-label: ${{ needs.start-runner.outputs.label }} | ||
folder: ${{ inputs.folder }} | ||
pr-sha: ${{ inputs.pr-sha }} | ||
ref: ${{ inputs.ref }} | ||
|
||
stop-runner: | ||
name: "π§ Stop EC2 runner" | ||
runs-on: ubuntu-latest | ||
needs: [start-runner, deploy-module] | ||
if: "success() || failure()" | ||
steps: | ||
- name: "π₯ Configure AWS Credentials" | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::262732185023:role/github-action-deploy-role | ||
aws-region: eu-west-1 | ||
retry-max-attempts: 5 | ||
- name: "β°οΈ Stop EC2 runner" | ||
uses: machulav/ec2-github-runner@v2 | ||
with: | ||
mode: stop | ||
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
label: ${{ needs.start-runner.outputs.label }} | ||
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} |
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,68 @@ | ||
name: "π Deploy submodule" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
runner-label: | ||
required: false | ||
type: string | ||
folder: | ||
required: true | ||
type: string | ||
pr-sha: | ||
required: true | ||
type: string | ||
ref: | ||
required: true | ||
type: string | ||
stage-override: | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
deploy-aws: | ||
runs-on: ${{ inputs.runner-label || 'ubuntu-latest' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.pr-sha }} | ||
|
||
- name: "π¨ Setup pnpm" | ||
uses: pnpm/action-setup@v3 | ||
with: | ||
run_install: false | ||
|
||
- name: "π¨ Setup Node.js" | ||
id: setup-node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: "pnpm" | ||
|
||
- name: "π§ Setup environment" | ||
shell: bash | ||
run: | | ||
if [[ "${{ inputs.ref }}" == "refs/heads/main" ]]; then | ||
echo "STAGE=prod" >> $GITHUB_ENV | ||
elif [[ "${{ inputs.ref }}" == "refs/heads/staging" ]]; then | ||
echo "STAGE=dev" >> $GITHUB_ENV | ||
fi | ||
- name: "π¨ Install dependencies" | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: "π₯ Configure AWS Credentials" | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::262732185023:role/github-action-deploy-role | ||
aws-region: eu-west-1 | ||
retry-max-attempts: 5 | ||
|
||
- name: "π SST Deploy" | ||
working-directory: ${{ inputs.folder }} | ||
env: | ||
STAGE_OVERRIDE: ${{ inputs.stage-override }} | ||
run: | | ||
STAGE=${STAGE_OVERRIDE:-$STAGE} | ||
echo "Deploying with stage: $STAGE" | ||
pnpm sst deploy --stage $STAGE |
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,37 @@ | ||
name: π Deploy | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- staging | ||
- ci/setup | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-deploy | ||
|
||
env: | ||
CI: true | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
# Independent step, deploying all the tools infrastructure | ||
deploy-indexer: | ||
name: "π Deploy Indexer" | ||
uses: ./.github/workflows/deploy-submodule-via-ec2.yml | ||
secrets: inherit | ||
with: | ||
# Need a custom ami image id since it's needing docker for the build process | ||
ami-image-id: ami-0e2a787a966f10c15 | ||
instance-type: t4g.small | ||
folder: ./tools | ||
pr-sha: ${{ github.event.pull_request.head.sha }} | ||
ref: ${{ github.ref }} |