-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from JoeyBarnes/main
Added a GitHub Actions Workflow to generate ARM and Bicep templates
- Loading branch information
Showing
17 changed files
with
1,769 additions
and
65 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Workflow for generating (arm/bicep/etc) templates for each alert | ||
name: Generate Templates | ||
|
||
on: | ||
# Runs on pushes targeting the default branch | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'services/**/alerts.yaml' | ||
- 'tooling/generate-templates/**' | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
generate-templates: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' # install the python version needed | ||
|
||
- name: Install Python Packages and Requirements | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
working-directory: tooling/generate-templates | ||
|
||
- name: Generate Templates | ||
id: generate | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git checkout -b github-action-generate-templates | ||
# Generate templates for alerts | ||
echo "Generating templates for alerts..." | ||
python tooling/generate-templates/generate-templates.py --path services --output services --template_path tooling/generate-templates/templates | ||
# Check if there are any changes in the services directory | ||
git add services | ||
# Check if there are any changes to commit | ||
if [[ `git status --porcelain` ]]; then | ||
git commit -m "[GitHub Action - Generate Templates] Generate templates for alerts" | ||
# Push changes to the current branch | ||
git push --set-upstream origin github-action-generate-templates --force | ||
prs=$(gh pr list \ | ||
--repo "$GITHUB_REPOSITORY" \ | ||
--head 'github-action-generate-templates' \ | ||
--base 'main' \ | ||
--json title \ | ||
--jq 'length') | ||
if ((prs > 0)); then | ||
echo "skippr=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
else | ||
echo "skippr=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Create pull request | ||
if: '!steps.generate.outputs.skippr' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Create a pull request | ||
echo "Creating a pull request..." | ||
gh pr --repo ${{ github.repository }} create --title "[GitHub Action - Generate Templates] Generate templates for alerts" --body "This PR was automatically generated by the workflow." --base main --head github-action-generate-templates | ||
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
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
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
Oops, something went wrong.