-
Notifications
You must be signed in to change notification settings - Fork 4
170 lines (141 loc) · 6.37 KB
/
deploy_preview.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Deploy Preview
on:
issue_comment:
types: [created]
jobs:
deploy_preview:
if: (startsWith(github.event.comment.body, '🚀') || startsWith(github.event.comment.body, ':rocket:')) && github.event.issue.pull_request
name: Deploy Preview ${{ github.event.issue.number }}
runs-on: ubuntu-latest
steps:
- name: Comment PR Preview
uses: thollander/actions-comment-pull-request@v2
with:
message: "Preview environment is decomissioned."
comment_tag: deployment
mode: recreate
pr_number: ${{ github.event.issue.number }}
# deploy_preview:
# if: (startsWith(github.event.comment.body, '🚀') || startsWith(github.event.comment.body, ':rocket:')) && github.event.issue.pull_request
# concurrency:
# group: ${{ github.workflow }}-${{ github.event.issue.id }}
# cancel-in-progress: true
# name: Deploy Preview ${{ github.event.issue.number }}
# runs-on: ubuntu-latest
# steps:
# - name: Get Run URL
# id: run_url
# run: echo "url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT"
# - name: Comment PR Preview
# if: github.event.issue.state != 'closed'
# uses: thollander/actions-comment-pull-request@v2
# with:
# message: |
# ### :rocket: Prévisualisation
# Deploying a new preview, follow progress in ${{ steps.run_url.outputs.url }}
# comment_tag: deployment
# mode: recreate
# pr_number: ${{ github.event.issue.number }}
# - name: React to comment
# uses: dkershner6/reaction-action@v2
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# commentId: ${{ github.event.comment.id }}
# reaction: "+1"
# - id: "get-branch"
# run: echo "branch=$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')" >> "$GITHUB_OUTPUT"
# env:
# REPO: ${{ github.repository }}
# PR_NO: ${{ github.event.issue.number }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Checkout
# uses: actions/checkout@v4
# with:
# ref: ${{ steps.get-branch.outputs.branch }}
# - name: Create LFS file list
# run: git lfs ls-files --long | cut -d ' ' -f1 | sort > .lfs-assets-id
# - name: LFS Cache
# uses: actions/cache@v4
# with:
# path: .git/lfs/objects
# key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}
# restore-keys: |
# ${{ runner.os }}-lfs-
# - name: Git LFS Pull
# run: git lfs pull
# - name: Install SSH key
# uses: shimataro/ssh-key-action@v2
# with:
# name: github_actions
# key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
# known_hosts: ${{ vars.SSH_KNOWN_HOSTS }}
# config: |
# Host *
# IdentityFile ~/.ssh/github_actions
# - name: Create vault pwd file
# run: echo ${{ secrets.VAULT_PWD }} > .infra/.vault_pwd.txt
# - name: Encrypt logs
# run: .bin/mna-tdb deploy:log:encrypt
# if: always()
# env:
# ANSIBLE_VAULT_PASSWORD_FILE: .infra/.vault_pwd.txt
# - name: Run playbook
# run: .bin/mna-tdb deploy preview "${{ github.event.issue.number }}"
# env:
# ANSIBLE_VAULT_PASSWORD_FILE: .infra/.vault_pwd.txt
# ANSIBLE_REMOTE_USER: deploy
# ANSIBLE_BECOME_PASS: ${{ secrets.DEPLOY_PASS }}
# - name: Add Job summary
# if: always()
# run: echo 'You can get logs using `.bin/mna-tdb deploy:log:decrypt ${{ github.run_id }} ${{ github.event.issue.number }}`' >> $GITHUB_STEP_SUMMARY
# - name: Upload logs artifacts
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: logs-${{ github.event.issue.number }}
# path: /tmp/deploy.log.gpg
# - name: Add Job summary
# if: always()
# run: echo 'You can get logs using `.bin/mna-tdb deploy:log:decrypt ${{ github.run_id }} ${{ github.event.issue.number }}`' >> $GITHUB_STEP_SUMMARY
# - name: Preview Summary when failed
# if: failure()
# run: echo 'You can get error logs using `.bin/mna-tdb deploy:log:decrypt ${{ github.run_id }}`' >> $GITHUB_STEP_SUMMARY
# - name: Preview Summary
# run: echo 'https://${{ github.event.issue.number }}.tdb-preview.apprentissage.beta.gouv.fr/ 🚀' >> $GITHUB_STEP_SUMMARY
# - name: Comment PR Preview
# if: github.event.issue.state != 'closed'
# uses: thollander/actions-comment-pull-request@v2
# with:
# message: |
# ### :rocket: Prévisualisation
# https://${{ github.event.issue.number }}.tdb-preview.apprentissage.beta.gouv.fr/
# You can access runner logs in ${{ steps.run_url.outputs.url }}
# To re-deploy just add a comment with :rocket:
# comment_tag: deployment
# mode: recreate
# pr_number: ${{ github.event.issue.number }}
# - name: Comment PR Preview when failed
# if: failure() && github.event.issue.state != 'closed'
# uses: thollander/actions-comment-pull-request@v2
# with:
# message: |
# ### :ambulance: Prévisualisation failed
# https://${{ github.event.issue.number }}.tdb-preview.apprentissage.beta.gouv.fr/
# You can get error logs using `.bin/mna-tdb deploy:log:decrypt ${{ github.run_id }}`
# You can access runner logs in ${{ steps.run_url.outputs.url }}
# To re-deploy just add a comment with :rocket:
# comment_tag: deployment
# mode: recreate
# pr_number: ${{ github.event.issue.number }}
# - name: Comment PR Preview when cancelled
# if: cancelled() && github.event.issue.state != 'closed'
# uses: thollander/actions-comment-pull-request@v2
# with:
# message: |
# ### :ambulance: Prévisualisation cancelled
# https://${{ github.event.issue.number }}.tdb-preview.apprentissage.beta.gouv.fr/
# You can access runner logs in ${{ steps.run_url.outputs.url }}
# To re-deploy just add a comment with :rocket:
# comment_tag: deployment
# mode: recreate
# pr_number: ${{ github.event.issue.number }}