Skip to content

Commit 4a2a6e5

Browse files
authored
Merge pull request #16 from benjamin-747/main
feat: init action file
2 parents 3efd9fc + e746c43 commit 4a2a6e5

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/bot-deploy.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: R2CN Bot deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
deploy-app:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 30
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Configure AWS Credentials
20+
uses: aws-actions/configure-aws-credentials@v4
21+
with:
22+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24+
aws-region: us-east-1
25+
26+
- name: Login to Amazon ECR Public
27+
id: login-ecr-public
28+
uses: aws-actions/amazon-ecr-login@v2
29+
with:
30+
registry-type: public
31+
32+
- name: Build, tag, and push docker image to Amazon ECR Public
33+
env:
34+
REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
35+
REGISTRY_ALIAS: m8q5m4u3
36+
REPOSITORY: r2cn
37+
IMAGE_TAG: bot-0.1.0-pre-release
38+
run: |
39+
40+
IMAGE_BASE="$REGISTRY/$REGISTRY_ALIAS/$REPOSITORY"
41+
42+
docker buildx build \
43+
-t $IMAGE_BASE:$IMAGE_TAG \
44+
--push .
45+
46+
- name: Deploy via SSH
47+
uses: appleboy/ssh-action@v1.0.3
48+
with:
49+
host: ${{ secrets.SSH_HOST }}
50+
username: ${{ secrets.SSH_USER }}
51+
key: ${{ secrets.SSH_PRIVATE_KEY }}
52+
port: ${{ secrets.SSH_PORT }}
53+
script: |
54+
docker pull public.ecr.aws/m8q5m4u3/r2cn:bot-0.1.0-pre-release &&
55+
docker rm -f r2cn-bot || true &&
56+
docker run -it -d --name r2cn-bot --network r2cn-network \
57+
-e APP_ID=${{ secrets.APP_ID}} \
58+
-e PRIVATE_KEY=${{secrets.PRIVATE_KEY}} \
59+
-e WEBHOOK_SECRET=${{secrets.WEBHOOK_SECRET}} \
60+
-e GITHUB_CLIENT_ID=${{secrets.APP_CLIENT_ID}} \
61+
-e GITHUB_CLIENT_SECRET=${{secrets.APP_CLIENT_SECRET}} \
62+
-e API_ENDPOINT=http://r2cn-api:8000/api/v1 \
63+
-p 3000:3000 --restart=always \
64+
public.ecr.aws/m8q5m4u3/r2cn:bot-0.1.0-pre-release

0 commit comments

Comments
 (0)