generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 4
85 lines (73 loc) · 2.17 KB
/
ec2-deployment.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
name: Build and Deploy Ciphernode
on:
push:
branches:
- release
- main
paths:
- 'packages/ciphernode/**'
- 'packages/evm/contracts/**'
pull_request:
branches:
- release
- main
paths:
- 'packages/ciphernode/**'
- 'packages/evm/contracts/**'
env:
DOCKERFILE_PATH: packages/ciphernode/Dockerfile
IMAGE_NAME: ghcr.io/gnosisguild/ciphernode
permissions:
contents: read
packages: write
jobs:
build:
name: Build Image
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Generate version tag
id: version
run: echo "version=$(date +'%Y%m%d')-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
env:
IMAGE_TAG: ${{ steps.version.outputs.version }}
run: |
docker build -t $IMAGE_NAME:${{ steps.version.outputs.version }} -f $DOCKERFILE_PATH .
docker push $IMAGE_NAME:$IMAGE_TAG
- name: Push to GHCR
if: github.ref == 'refs/heads/release'
env:
IMAGE_TAG: ${{ steps.version.outputs.version }}
run: |
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:latest
docker push $IMAGE_NAME:latest
deploy:
name: Deploy to Production
needs: build
runs-on: ubuntu-latest
environment:
name: production
if: github.ref == 'refs/heads/release'
steps:
- name: Deploy to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script: |
IMAGE_TAG="${{ needs.build.outputs.image_tag }}"
echo "Deploying version: $IMAGE_TAG"
docker pull $IMAGE_NAME:$IMAGE_TAG
cd /home/ec2-user/enclave
git pull
./deploy/deploy.sh enclave $IMAGE_NAME:$IMAGE_TAG