-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (53 loc) · 1.48 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
name: Deploy API
on:
push:
branches:
- main
workflow_dispatch:
inputs:
environment:
type: choice
options:
- deploy-dev
- deploy-prod
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: adopt
- name: Build the app with Maven
run: mvn -B clean install --file pom.xml -DskipTests
- name: Settings
uses: kanga333/variable-mapper@v0.2.2
id: settings
with:
key: ${{ github.event.inputs.environment || github.ref_name }}
map: |
{
"^main$": {
"environment": "deploy-dev"
},
".*": {
"environment": "${{ github.event.inputs.environment }}"
}
}
export_to: output,log
mode: fill
- name: Deploy the app
working-directory: ./ansible
run: |
echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > ansible.key
ansible-galaxy install -r requirements.yml
ansible-playbook playbook.yml \
--inventory=secrets.yml \
--extra-vars='servers=${{ steps.settings.outputs.environment }}' \
--vault-password-file=ansible.key
rm -f ansible.key
env:
ANSIBLE_HOST_KEY_CHECKING: 'false'