-
Notifications
You must be signed in to change notification settings - Fork 26
94 lines (92 loc) · 3.68 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Reusable build
on:
workflow_call:
inputs:
build-env:
required: true
type: string
secrets:
MAILCHIMP_DC:
required: true
MAILCHIMP_KEY:
required: true
MAILCHIMP_LIST_ID:
required: true
NEXT_PUBLIC_RECAPTCHA_KEY:
required: true
NEXT_PUBLIC_STRAPI_EMAIL:
required: true
NEXT_PUBLIC_STRAPI_PASSWORD:
required: true
DEPLOY_HOST:
required: true
DEPLOY_USER:
required: true
DEPLOY_PATH:
required: true
DEPLOY_INSTANCES_NUM:
required: true
DEPLOY_PRIVATE_KEY:
required: true
DOCKER_REGISTRY_ADDRESS:
required: true
DOCKER_REGISTRY_NAMESPACE:
required: true
DOCKER_REGISTRY_USERNAME:
required: true
DOCKER_REGISTRY_PASSWORD:
required: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.build-env }}
env:
MAILCHIMP_DC: ${{ secrets.MAILCHIMP_DC }}
MAILCHIMP_KEY: ${{ secrets.MAILCHIMP_KEY }}
MAILCHIMP_LIST_ID: ${{ secrets.MAILCHIMP_LIST_ID }}
NEXT_PUBLIC_RECAPTCHA_KEY: ${{ secrets.NEXT_PUBLIC_RECAPTCHA_KEY }}
NEXT_PUBLIC_STRAPI_EMAIL: ${{ secrets.NEXT_PUBLIC_STRAPI_EMAIL }}
NEXT_PUBLIC_STRAPI_PASSWORD: ${{ secrets.NEXT_PUBLIC_STRAPI_PASSWORD }}
DOCKER_CONTAINER_NAME: tidb-community-website
DOCKER_IMAGE_NAME: tidb-community-website
steps:
- uses: actions/checkout@v3
- name: rsync deploy directory
uses: burnett01/[email protected]
with:
switches: -avzr --delete
path: deploy/
remote_path: ${{ secrets.DEPLOY_PATH }}/deploy
remote_host: ${{ secrets.DEPLOY_HOST }}
# remote_port: ${{ secrets.DEPLOY_PORT }}
remote_user: ${{ secrets.DEPLOY_USER }}
remote_key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
- name: Dump envs
run: |
cat .env.${{ inputs.build-env }} >> .env.local
echo MAILCHIMP_DC=${{ secrets.MAILCHIMP_DC }} >> .env.local
echo MAILCHIMP_KEY=${{ secrets.MAILCHIMP_KEY }} >> .env.local
echo MAILCHIMP_LIST_ID=${{ secrets.MAILCHIMP_LIST_ID }} >> .env.local
echo NEXT_PUBLIC_RECAPTCHA_KEY=${{ secrets.NEXT_PUBLIC_RECAPTCHA_KEY }} >> .env.local
echo NEXT_PUBLIC_STRAPI_EMAIL=${{ secrets.NEXT_PUBLIC_STRAPI_EMAIL }} >> .env.local
echo NEXT_PUBLIC_STRAPI_PASSWORD=${{ secrets.NEXT_PUBLIC_STRAPI_PASSWORD }} >> .env.local
- name: rsync env files
uses: burnett01/[email protected]
with:
switches: -avzr --delete
path: .env.local
remote_path: ${{ secrets.DEPLOY_PATH }}/deploy/server
remote_host: ${{ secrets.DEPLOY_HOST }}
# remote_port: ${{ secrets.DEPLOY_PORT }}
remote_user: ${{ secrets.DEPLOY_USER }}
remote_key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
- name: Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
envs: DOCKER_CONTAINER_NAME,DOCKER_IMAGE_NAME,DOCKER_IMAGE_TAG
script: |
echo '${{ secrets.DOCKER_REGISTRY_PASSWORD }}' | sudo docker login ${{ secrets.DOCKER_REGISTRY_ADDRESS }}/${{ secrets.DOCKER_REGISTRY_NAMESPACE }} --username ${{ secrets.DOCKER_REGISTRY_USERNAME }} --password-stdin
cd ${{ secrets.DEPLOY_PATH }}/deploy && chmod +x ./deploy.sh && sh ./deploy.sh server ${DOCKER_CONTAINER_NAME} ${{ secrets.DOCKER_REGISTRY_ADDRESS }} ${{ secrets.DOCKER_REGISTRY_NAMESPACE }} ${DOCKER_IMAGE_NAME} ${{ inputs.build-env }}-${{ runner.os }}-${{ github.sha }}