|
| 1 | +name: "[Icon] Icon update approved" |
| 2 | +on: |
| 3 | + issues: |
| 4 | + types: [labeled] |
| 5 | + |
| 6 | +jobs: |
| 7 | + update-icon: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + # This condition ensures the job only runs when the 'approved' label is updated and the issue title starts with 'feat(icons): update ' |
| 10 | + if: | |
| 11 | + contains(github.event.issue.labels.*.name, 'approved') && |
| 12 | + startsWith(github.event.issue.title, 'feat(icons): update ') |
| 13 | + env: |
| 14 | + ICON_TYPE: ${{ contains(github.event.issue.labels.*.name, 'normal-icon') && 'normal' || 'monochrome' }} |
| 15 | + steps: |
| 16 | + - name: Obtain token |
| 17 | + id: obtainToken |
| 18 | + uses: tibdex/github-app-token@v2 |
| 19 | + with: |
| 20 | + private_key: ${{ secrets.DASHBOARD_ICONS_MANAGER_APP_PRIVATE_KEY }} |
| 21 | + app_id: ${{ vars.DASHBOARD_ICONS_MANAGER_APP_ID }} |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + env: |
| 25 | + GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }} |
| 26 | + - name: Set Up Python |
| 27 | + uses: actions/setup-python@v4 |
| 28 | + with: |
| 29 | + python-version: "3.11" |
| 30 | + - name: Install Dependencies |
| 31 | + run: | |
| 32 | + pip install cairosvg pillow requests |
| 33 | + - name: Parse issue form |
| 34 | + id: parse_issue_form |
| 35 | + run: echo "ISSUE_FORM=$(python scripts/parse_issue_form.py)" >> "$GITHUB_OUTPUT" |
| 36 | + env: |
| 37 | + INPUT_ISSUE_BODY: ${{ github.event.issue.body }} |
| 38 | + - name: Update metadata file |
| 39 | + run: python scripts/generate_metadata_file.py ${{ env.ICON_TYPE }} update |
| 40 | + env: |
| 41 | + INPUT_ISSUE_FORM: ${{ steps.parse_issue_form.outputs.ISSUE_FORM }} |
| 42 | + INPUT_ISSUE_AUTHOR_ID: ${{ github.event.issue.user.id }} |
| 43 | + INPUT_ISSUE_AUTHOR_LOGIN: ${{ github.event.issue.user.login }} |
| 44 | + - name: Generate icons |
| 45 | + run: python scripts/generate_icons.py ${{ env.ICON_TYPE }} update |
| 46 | + env: |
| 47 | + INPUT_ISSUE_FORM: ${{ steps.parse_issue_form.outputs.ISSUE_FORM }} |
| 48 | + - name: Extract icon name |
| 49 | + id: extract_icon_name |
| 50 | + run: echo "ICON_NAME=$(python scripts/print_icon_name.py ${{ env.ICON_TYPE }} update)" >> "$GITHUB_OUTPUT" |
| 51 | + env: |
| 52 | + INPUT_ISSUE_FORM: ${{ steps.parse_issue_form.outputs.ISSUE_FORM }} |
| 53 | + - name: Commit changes |
| 54 | + run: | |
| 55 | + git config --global user.email "193821040+dashboard-icons-manager[bot]@users.noreply.github.com" |
| 56 | + git config --global user.name "Dashboard Icons Manager" |
| 57 | + git add . |
| 58 | + git commit -m "feat(icons): update ${{ steps.extract_icon_name.outputs.ICON_NAME }}" |
| 59 | +
|
| 60 | + - name: Create Pull Request |
| 61 | + uses: peter-evans/create-pull-request@v7 |
| 62 | + with: |
| 63 | + token: ${{ steps.obtainToken.outputs.token }} |
| 64 | + branch: icons/update-${{steps.extract_icon_name.outputs.ICON_NAME}} |
| 65 | + base: main |
| 66 | + title: "feat(icons): update ${{steps.extract_icon_name.outputs.ICON_NAME}}" |
| 67 | + delete-branch: true |
| 68 | + body: | |
| 69 | + This PR updates the icon ${{steps.extract_icon_name.outputs.ICON_NAME}} like requested in #${{github.event.issue.number}} to the project. |
0 commit comments