-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (60 loc) · 2.38 KB
/
deploy.yml
File metadata and controls
88 lines (60 loc) · 2.38 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
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
name: 'deploy'
on:
workflow_call:
inputs:
app:
description: 'the app name'
default: ''
required: true
type: string
ansible_repo:
description: 'the ansible repository'
required: true
default: 'atlas-aws-test'
type: string
env:
checkout_path: ${{ github.run_number }}
checkout_full_path: ${{ github.workspace }}/${{ github.run_number }}
docker_image: registry.gitlab.com/atlasconsulting/devops/atlas-aws-test:v1.5
docker_name: deploy-${{ github.sha }}
jobs:
build:
runs-on: self-hosted
name: 'Build package'
steps:
#TODO: verify if build already exists
- name: 'docker pull image'
run: docker pull ${{ env.docker_image }}
- name: 'checkout'
uses: 'actions/checkout@v3'
with:
path: ${{ env.checkout_path }}
- name: 'docker run image'
run: |
docker run -d --rm --mount type=bind,source=${{ env.checkout_full_path }},target=/home --name=${{ env.docker_name }} ${{ env.docker_image }} -c "/bin/sleep 300"
- name: 'docker exec composer install'
run: docker exec ${{ env.docker_name }} bash -c "cd /home && composer install --prefer-dist --no-interaction"
- name: 'ansible update'
run: ansible-update.sh atlas_aws_test
- name: 'set permissions'
run: sudo chown -R www-data:www-data ${{ env.checkout_full_path }}
- name: 'creating package'
run: cd /opt/ansible/atlas_aws_test && venv/bin/ansible-playbook package-apps.yml --extra-vars "{\"deploy\":[\"${{ inputs.app }}\"]}" --extra-vars "{\"pack_suffix\":\"${{ github.sha }}\"}" --extra-vars "{\"deploy_options\":{\"${{ inputs.app }}\":{\"mount\":\"${{ env.checkout_full_path }}\"}}}"
deploy:
needs: build
runs-on: self-hosted
name: 'Deploy'
steps:
- name: 'ansible update'
run: ansible-update.sh ${{ inputs.ansible_repo }}
- name: 'deploying package'
run: |
cd /opt/ansible/${{ inputs.ansible_repo }} && venv/bin/ansible-playbook s3-deploy-apps.yml --extra-vars "{\"pack_suffix\":\"${{ github.sha }}\"}" --extra-vars "{\"deploy\": [\"${{ inputs.app }}\"], \"archive\":\"yes\"}"
cleanup:
if: ${{ always() }}
needs: [build, deploy]
runs-on: self-hosted
name: 'Cleanup'
steps:
- name: 'cleanup'
run: sudo rm -rf ${{ env.checkout_full_path }}