update_templates #104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |