-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (57 loc) · 1.79 KB
/
deploy-stack.yml
File metadata and controls
62 lines (57 loc) · 1.79 KB
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
on:
workflow_call:
inputs:
environment:
required: false
description: Environment
type: string
default: staging
version:
required: false
description: Version
type: string
default: latest
secrets:
ssh_public_key:
description: SSH public key
required: true
ssh_private_key:
description: SSH private key
required: true
ssh_host:
description: SSH host
required: true
ssh_username:
description: SSH username
required: true
env:
APP_NAME: ${{ github.event.repository.name }}
APP_ENV: ${{ inputs.environment }}
APP_VERSION: ${{ inputs.version }}
jobs:
docker-compose:
runs-on: self-hosted
concurrency:
group: ${{ github.event.repository.name }}-docker-${{ inputs.environment }}
cancel-in-progress: false
env:
DOCKER_CONTEXT: ${{ env.APP_NAME }}-${{ env.APP_ENV }}
DOCKER_REPOSITORY: ${{ secrets.DOCKER_REGISTRY }}/${{ env.APP_NAME }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Set SSH context
uses: arwynfr/actions-docker-context@v2
with:
docker_host: ssh://${{ inputs.ssh_username }}@${{ inputs.ssh_host }}
context_name: ${{ env.DOCKER_CONTEXT }}
ssh_cert: ${{ secrets.ssh_public_key }}
ssh_key: ${{ secrets.ssh_private_key }}
- name: Login Docker registry
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REPOSITORY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy stack
run: docker --context ${{ env.DOCKER_CONTEXT }} stack deploy --compose-file docker-compose.yml ${{ env.APP_NAME }}