-
Notifications
You must be signed in to change notification settings - Fork 22
76 lines (65 loc) · 2.06 KB
/
docker-deployment.yaml
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
name: Deploy Workflow
on:
workflow_dispatch:
inputs:
deployment:
type: boolean
description: 'Deploy after build?'
required: false
default: false
environment:
type: choice
description: 'Select the environment to deploy to'
options:
- staging
- prod
- shimmer-staging
- shimmer-prod
required: false
default: staging
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
password: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}
#- name: Get the version
# id: get_version
# run: echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV
- name: Get the short commit hash
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "VERSION=$COMMIT_HASH" >> $GITHUB_ENV
- name: Set up Environment Variable
run: echo "DEPLOY_ENV=${{ github.event.inputs.environment }}" >> $GITHUB_ENV
- name: Build and push API Docker image
uses: docker/build-push-action@v2
with:
context: ./api
file: ./api/Dockerfile
push: true
tags: iotaledger/explorer-api:${{ env.VERSION }}
no-cache: true
- name: Build and push Client Docker image
uses: docker/build-push-action@v2
with:
context: ./client
file: ./client/Dockerfile
push: true
tags: iotaledger/explorer-client:${{ env.VERSION }}
no-cache: true
- name: Add SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.UPDATER_SSH_PRIVATE_KEY }}
- name: Deploy to Server
if: ${{ github.event.inputs.deployment }}
run: |
ssh -o StrictHostKeyChecking=no updater@${{ secrets.EXPLORER_GATEWAY }} "${{ env.DEPLOY_ENV }} ${{ env.VERSION }}"