Add namespace-node-affinity-operator main
branch
#59
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: Add charm branch | |
on: | |
issues: | |
types: | |
- opened | |
jobs: | |
add-charm: | |
name: Add charm branch to charms.json | |
if: ${{ contains(github.event.issue.labels.*.name, 'add-charm') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upgrade pip | |
run: pip install --upgrade pip | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install CLI | |
run: pipx install ./cli/ | |
- name: Add charm to charms.json | |
id: add-charm | |
run: add-charm '${{ github.event.issue.body }}' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create pull request | |
if: ${{ fromJSON(steps.add-charm.outputs.success) }} | |
run: | | |
branch="add-charm-$(date +%s)" | |
git checkout -b "$branch" | |
git add charms.json | |
git config user.name "GitHub Actions" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git commit -m '${{ steps.add-charm.outputs.title }}' | |
# Uses token set in checkout step | |
git push origin "$branch" | |
# Uses GH_TOKEN environment variable | |
pr_url=$(gh pr create --head "$branch" --title '${{ steps.add-charm.outputs.title }}' --body 'Closes #${{ github.event.issue.number }}' --label add-charm) | |
gh pr merge "$pr_url" --squash | |
# Build workflow will not be automatically triggered after PR is merged | |
# (Events caused by Github Actions will not trigger other GitHub Actions: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs) | |
gh workflow run build.yaml | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Comment error on GitHub issue | |
if: ${{ !fromJSON(steps.add-charm.outputs.success) }} | |
run: gh issue comment '${{ github.event.issue.number }}' --body '${{ steps.add-charm.outputs.error }}' --repo '${{ github.repository }}' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
permissions: | |
contents: write # Needed to push branch | |
pull-requests: write # Needed to create & merge pull request | |
actions: write # Needed to trigger build.yaml workflow | |
issues: write # Needed to create GitHub issue comment |