DEV Community

Outvi V
Outvi V

Posted on

Asset download, upload and metadata update all in one

My Workflow

This actions is designed to, with the help of a GitHub bot:

  • Accept clip and metadata input from a comment in issues
  • Clip the asset according to the comment
  • Download the asset and put it in the correct location (here begin the action part)
  • Fill in the metadata
  • Make a commit and push as a PR

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

name: "Auto PR for new sound"

on:
  issue_comment:
    types: [created, edited]

jobs:
  push_to_branch_and_create_pr:
    name: Create a PR with the sound
    if: "(contains(github.event.comment.body, ' pr ')) && ((contains(github.event.comment.author_association, 'OWNER') || contains(github.event.comment.user.login, 'librehsbot')) && (github.event.issue.number == 1))"
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
        name: Check out current commit

      - uses: suisei-cn/actions-download-file@v1
        id: downloadfile
        name: Download the file
        with:
          url: ${{ github.event.comment.body }}
          target: assets
          auto-match: true

      - uses: suisei-cn/actions-update-metadata@v2
        id: updatemeta
        name: Update sounds.yml
        with:
          comment: ${{ github.event.comment.body }}
          target: sounds.yml
          default-username: librehsbot
          format: yaml

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v2.8.0
        with:
          committer: Suisei Bot <noreply@suisei.moe>
          author: ${{ steps.updatemeta.outputs.username }} <${{ steps.updatemeta.outputs.username }}@users.noreply.github.com>
          commit-message: "feat(sound): Add ${{ steps.downloadfile.outputs.filename }}"
          title: "feat(sound): Add ${{ steps.downloadfile.outputs.filename }}"
          body: |
            This is an automated sound addition PR. Netlify preview should be available soon, and a preview link should be shown.

            <sub>Having problems? Check your [workflow](https://github.com/suisei-cn/sbtn-assets/blob/master/.github/workflows/auto_pr.yml).</sub>
          branch: sound/new
          branch-suffix: "random"
          labels: new-sound

auto_pr.yml

GitHub logo suisei-cn / sbtn-assets

Starbuttons assets.

Additional Resources / Info

Top comments (0)