Issues with backup preparation times #32
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: Version Target | |
| on: issue_comment | |
| jobs: | |
| check-permission: | |
| runs-on: ubuntu-latest | |
| if: ${{ !github.event.issue.pull_request && contains(github.event.comment.body,'!target') }} | |
| name: Check permission | |
| steps: | |
| # Check for write permission | |
| - name: Check user permission | |
| id: check | |
| uses: scherermichael-oss/action-has-permission@master | |
| with: | |
| required-permission: write | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Use the output from the `check` step | |
| - name: Run only if user has sufficient permissions | |
| if: steps.check.outputs.has-permission | |
| run: exit 0 #Successful | |
| - name: Run only if user has NOT sufficient permissions | |
| if: "! steps.check.outputs.has-permission" | |
| run: exit 1 #Failed | |
| run-command: | |
| name: Run label check | |
| needs: [check-permission] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get Version | |
| id: version | |
| run: | | |
| echo "${{ github.event.comment.body }}" | |
| X=`echo "${{ github.event.comment.body }}" | grep -o '!target.*' | awk '{print $2}'`; echo "Target: $X" | |
| if [[ ${X,,} = v* ]] | |
| then | |
| Y="${X,,}" | |
| else | |
| Y="v${X,,}" | |
| fi | |
| echo VERSION="Target : ${Y%.}" >> "$GITHUB_OUTPUT" | |
| - name : "Create label if it doesn't exist" | |
| id: create-label | |
| run: | | |
| if ! gh label list | grep -q "${{ steps.version.outputs.VERSION }}"; then | |
| echo "Label doesn't exist, creating" | |
| gh label create "${{ steps.version.outputs.VERSION }}" --description "A release target." --color 4900CB | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} #this has to be specified because i'm not checking out the repo | |
| - name : "Assign label to the target issue" | |
| id: assign-label | |
| run: | | |
| gh issue edit ${{ github.event.issue.number }} --add-label "${{ steps.version.outputs.VERSION }}" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} #this has to be specified because i'm not checking out the repo |