add-package #17
This file contains hidden or 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 package to repository" | |
| on: | |
| repository_dispatch: | |
| types: [add-package] | |
| workflow_dispatch: | |
| inputs: | |
| urls: | |
| description: "URLs of the packages to add" | |
| required: true | |
| component: | |
| description: "Component to add the packages to" | |
| required: true | |
| default: "rpi" | |
| jobs: | |
| add-package: | |
| name: "Add package" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| path: checkout | |
| - name: Fetch package | |
| id: fetch | |
| run: | | |
| if [[ "${{ github.event_name }}" = "repository_dispatch" && "${{ github.event.action }}" = "add-package" ]]; then | |
| URLS="${{ github.event.client_payload.urls }}" | |
| COMPONENT="${{ github.event.client_payload.component }}" | |
| else | |
| URLS="${{ github.event.inputs.urls }}" | |
| COMPONENT="${{ github.event.inputs.component }}" | |
| fi | |
| echo "URLs: $URLS" | |
| echo "COMPONENT: $COMPONENT" | |
| # download packages | |
| for u in $URLS ; do | |
| curl -LOJ $u | |
| done | |
| # figure out file and package name | |
| debs=(*.deb) | |
| name=$(echo ${debs[0]} | cut -d_ -f1) | |
| # copy debs to repo | |
| for d in ${debs[*]}; do | |
| dist=$(echo $d | rev | cut -d"." -f2 | rev | cut -d"_" -f1 | cut -d"-" -f1) | |
| target=checkout/pool/$dist/$COMPONENT/$name | |
| mkdir -p $target && mv $d $target | |
| done | |
| echo "DEBS=${debs[*]}" >> $GITHUB_ENV | |
| echo "COMPONENT=$COMPONENT" >> $GITHUB_ENV | |
| echo "PACKAGE=$name" >> $GITHUB_ENV | |
| - name: Create PR | |
| uses: peter-evans/create-pull-request@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| path: checkout | |
| commit-message: "chore: add debs for ${{ env.PACKAGE }} and component ${{ env.COMPONENT }}" | |
| committer: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>" | |
| author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>" | |
| branch: "add-debs/${{ env.COMPONENT }}-${{ env.PACKAGE}}" | |
| title: "Add deb(s) for ${{ env.PACKAGE }} and component ${{ env.COMPONENT }}" | |
| body: | | |
| This PR adds the deb(s) ${{ env.DEBS }} for package ${{ env.PACKAGE }} and component ${{ env.COMPONENT }} to the apt repository. | |
| Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request) | |
| delete-branch: true |