This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
forked from JoshOrndorff/substrate-node-template
-
Notifications
You must be signed in to change notification settings - Fork 23
95 lines (83 loc) · 2.5 KB
/
docker-build.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
95
name: Build and deploy node
on:
pull_request:
types:
- closed
branches:
- master
workflow_dispatch:
jobs:
build:
if: contains( github.event.pull_request.labels.*.name, 'CI')
name: Create & push Docker image
runs-on: [ self-hosted, linux, x64, standalone ]
steps:
- uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="dappforce/subsocial-node"
echo ::set-output name=tagged_image::${IMAGE}:${TAG}
echo ::set-output name=tag::${TAG}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Build production image
uses: docker/build-push-action@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: docker/Dockerfile
push: true
tags: |
${{ steps.prep.outputs.tagged_image }}
dappforce/subsocial-node:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
deploy_1:
name: deploy-validator-1
needs: build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /home/ops/
./validator.sh
deploy_2:
name: deploy-validator-2
needs: deploy_1
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_2 }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd /home/ops/
./validator.sh