Skip to content

Create issue if URL of SHV SDK returns status code 404 (Not Found) #38

Create issue if URL of SHV SDK returns status code 404 (Not Found)

Create issue if URL of SHV SDK returns status code 404 (Not Found) #38

name: Create issue if URL of SHV SDK returns status code 404 (Not Found)
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
create_issue:
name: Create issue if URL of SHV SDK is not found
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Set up const strings
id: const-strings
run: |
echo "sdk-url=http://www.dev-c.com/files/ScriptHookV_SDK_1.0.3337.0.zip" >> $GITHUB_OUTPUT
- name: Test if URL of SHV SDK returns status code 404 (Not Found)
id: status-code-check
run: |
SDK_URL=${{ steps.const-strings.outputs.sdk-url }}
STATUS_CODE=$(curl -s -o /dev/null -H 'Referer: http://www.dev-c.com/gtav/scripthookv/' -w '%{http_code}' ${SDK_URL})
echo "shv-sdk-status-code=${STATUS_CODE}" >> $GITHUB_OUTPUT
echo "Status Code from '${SDK_URL}': ${STATUS_CODE}"
if [[ $STATUS_CODE != "404" ]]; then
echo "Status Code of the URL of SDV's SDK is not 404, skipping further steps. Status code: ${STATUS_CODE}"
fi
- name: Test if there is no open issues that have the "shv-sdk-not-found" label
if: ${{ steps.status-code-check.outputs.shv-sdk-status-code == '404' }}
id: prev-issue-test
run: |
previous_issue_number=$(gh issue list \
--label "$LABELS" \
--json number \
--jq '.[0].number')
echo "previous-issue-number=${previous_issue_number}" >> $GITHUB_OUTPUT
if [[ -n $previous_issue_number ]]; then
echo: "There is a issue that have the \"shv-sdk-not-found\" label, skipping further steps. Number of latest matching issue: ${previous_issue_number}"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
LABELS: deps-url-of-shv-sdk-not-found
- name: Create new issue
if: ${{ steps.prev-issue-test.outputs.previous-issue-number != '' }}
run: |
new_issue_url=$(gh issue create \
--title "$TITLE" \
--label "$LABELS" \
--body "$BODY")
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
TITLE: Current URL of SHV's SDK in `install_sdk.ps1` is unavailable
LABELS: deps-url-of-shv-sdk-not-found
BODY: |
The current URL of SHV's SDK in `install_sdk.ps1` is unavailable, which returns the status code 404. Should be replaced with the new URL.
Current URL: `${{ steps.const-strings.outputs.sdk-url }}`