-
Notifications
You must be signed in to change notification settings - Fork 11
69 lines (67 loc) · 2.34 KB
/
update_templates.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
name: update_templates
on:
workflow_dispatch:
inputs:
branch:
description: 'topaz branch to update from'
type: string
default: "main"
required: false
env:
VAULT_ADDR: https://vault.eng.aserto.com/
PR_BRANCH: topaz_templates_${{ inputs.branch }}
# If the source topaz branch isn't 'main', add a '[DO NOT MERGE]' prefix to the PR title
PR_TITLE: ${{ inputs.branch != 'main' && '[DO NOT MERGE] ' || '' }} Update topaz templates from ${{ inputs.branch }}
# If the source branch isn't 'main', create the PR as a draft
PR_DRAFT_FLAG: ${{ inputs.branch != 'main' && '--draft' || '' }}
jobs:
update:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v4
-
name: Read Configuration
uses: hashicorp/vault-action@v3
id: vault
with:
url: https://vault.eng.aserto.com/
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
kv/data/github "SSH_PRIVATE_KEY" | SSH_PRIVATE_KEY;
kv/data/github "READ_WRITE_TOKEN" | READ_WRITE_TOKEN;
-
name: Setup git
run: |
mkdir -p $HOME/.ssh
umask 0077 && echo -e "${SSH_PRIVATE_KEY}" > $HOME/.ssh/id_rsa
ssh-keyscan github.com >> $HOME/.ssh/known_hosts
git config --global url."[email protected]:".insteadOf https://github.com/
git config --global user.email "[email protected]"
git config --global user.name "Aserto Bot"
-
name: Get topaz
uses: actions/checkout@v4
with:
repository: "aserto-dev/topaz"
ref: ${{ inputs.branch }}
path: "./topaz"
token: ${READ_WRITE_TOKEN}
-
name: Copy assets
run: |
cp -r ./topaz/assets/* static/assets/templates/
rm static/assets/templates/*.gif
rm -rf ./topaz
-
name: Commit changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
new_branch: ${{ env.PR_BRANCH }}
message: Update static topaz template assets
-
name: Prepare PR
run: gh pr create ${{ env.PR_DRAFT_FLAG }} -H ${{ env.PR_BRANCH }} -B main --title '${{ env.PR_TITLE }}' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ steps.vault.outputs.READ_WRITE_TOKEN }}