Skip to content

Commit 4093627

Browse files
committed
feat(gh-actions): ✨ Added steps to upload infra to DO
1 parent 2844086 commit 4093627

File tree

1 file changed

+46
-16
lines changed

1 file changed

+46
-16
lines changed

.github/workflows/deploy-infra.yml

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,48 @@
11
on:
2-
workflow_call:
3-
inputs:
4-
artifact:
5-
required: true
6-
type: string
7-
environment:
8-
required: true
9-
type: string
2+
workflow_call:
3+
inputs:
4+
artifact:
5+
required: true
6+
type: string
7+
environment:
8+
required: true
9+
type: string
10+
secret_name:
11+
required: true
12+
type: string
1013
jobs:
11-
deploy_infra_artifact:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Build compose filename
15-
id: build-compose-filename
16-
run: |
17-
echo "Artifact: ${{ inputs.artifact }}"
18-
echo "Environment: ${{ inputs.environment }}"
14+
deploy_infra_artifact:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Build compose filename
18+
id: build-compose-filename
19+
run: |
20+
echo "Artifact: ${{ inputs.artifact }}"
21+
echo "Environment: ${{ inputs.environment }}"
22+
filename="${{ inputs.artifact }}-compose-${{ inputs.environment }}.yml"
23+
echo "Generated filename: $filename"
24+
echo "COMPOSE_FILENAME=$filename" >> $GITHUB_ENV
25+
26+
- name: Transfer Compose File to Server
27+
uses: appleboy/[email protected]
28+
with:
29+
host: ${{ secrets.SSH_HOST }}
30+
username: ${{ secrets.SSH_USERNAME }}
31+
key: ${{ secrets.SSH_KEY }}
32+
source: .github/workflows/infra/docker/postgres-compose-pre.yml
33+
target: /opt/summoners-sync/infra/docker/${{ env.COMPOSE_FILENAME }}
34+
rm: true
35+
36+
# Deploy Infra
37+
- name: Deploy Infra
38+
uses: appleboy/[email protected]
39+
with:
40+
host: ${{ secrets.SSH_HOST }}
41+
username: ${{ secrets.SSH_USERNAME }}
42+
key: ${{ secrets.SSH_KEY }}
43+
script: |
44+
cd /opt/summoners-sync/infra/docker
45+
46+
echo "${{ secrets[inputs.secret_name] }}" > .env
47+
48+
docker-compose --env-file .env -f ${{ env.COMPOSE_FILENAME }} up -d

0 commit comments

Comments
 (0)