Move tests files to .github/workflows

This commit is contained in:
Alvaro Muñoz
2024-02-08 11:55:21 +01:00
parent da2ac2af03
commit 1708e0f19d
12 changed files with 190 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
run-name: Cleanup ${{ github.head_ref }}
on:
pull_request_target:
types: labeled
paths:
- "images/**"
jobs:
clean_ci:
name: Clean CI runs
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
$startDate = Get-Date -UFormat %s
$workflows = @("macos11", "macos12", "ubuntu2004", "ubuntu2204", "windows2019", "windows2022")
while ($true) {
$continue = $false
foreach ($wf in $workflows) {
$skippedCommand = "gh run list --workflow ${wf}.yml --branch ${{ github.event.pull_request.head.ref }} --repo ${{ github.repository }} --status skipped --json databaseId"
$skippedIds = Invoke-Expression -Command $skippedCommand | ConvertFrom-Json | ForEach-Object { $_.databaseId }
$skippedIds | ForEach-Object {
$deleteCommand = "gh run delete --repo ${{ github.repository }} $_"
Invoke-Expression -Command $deleteCommand
}
$pendingCommand = "gh run list --workflow ${wf}.yml --branch ${{ github.event.pull_request.head.ref }} --repo ${{ github.repository }} --status requested --json databaseId --template '{{ . | len }}'"
$pending = Invoke-Expression -Command $pendingCommand
if ($pending -gt 0) {
Write-Host "Pending for ${wf}.yml: $pending run(s)"
$continue = $true
}
}
if ($continue -eq $false) {
Write-Host "All done, exiting"
break
}
$curDate = Get-Date -UFormat %s
if (($curDate - $startDate) -gt 60) {
Write-Host "Reached timeout, exiting"
break
}
Write-Host "Waiting 5 seconds..."
Start-Sleep -Seconds 5

View File

@@ -0,0 +1,55 @@
name: Image URL Processing
on:
issue_comment:
types: [created]
jobs:
process-image-url:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, 'https://github.com/github/release-assets/assets/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Extract and Clean Initial URL
id: extract-url
run: |
INITIAL_URL=$(echo "${{ github.event.comment.body }}" | grep -o 'https://github.com/github/release-assets/assets/[^ >]*')
echo "Cleaned Initial URL: $INITIAL_URL"
echo "::set-output name=initial_url::$INITIAL_URL"
- name: Get Redirected URL with Debugging
id: curl
run: |
REDIRECTED_URL=$(curl -L -o /dev/null -w %{url_effective} -sS "${{ steps.extract-url.outputs.initial_url }}")
echo "Curl Command Executed"
echo "Redirected URL: $REDIRECTED_URL"
echo "::set-output name=redirected_url::$REDIRECTED_URL"
- name: Trim URL after PNG
id: trim-url
run: |
TRIMMED_URL=$(echo "${{ steps.curl.outputs.redirected_url }}" | sed 's/\(.*\.png\).*/\1/')
echo "Trimmed URL: $TRIMMED_URL"
echo "::set-output name=trimmed_url::$TRIMMED_URL"
- name: Output Final Trimmed URL
run: |
echo "Final Trimmed Image URL: ${{ steps.trim-url.outputs.trimmed_url }}"
- name: Update Comment with New URL
run: |
COMMENT_URL="${{ github.event.comment.url }}"
NEW_COMMENT_BODY="Use this link to include this asset in your changelog: ${{ steps.trim-url.outputs.trimmed_url }}"
ORIGINAL_COMMENT_BODY="${{ github.event.comment.body }}"
UPDATED_COMMENT="${ORIGINAL_COMMENT_BODY} 👀 ${NEW_COMMENT_BODY}"
PAYLOAD=$(jq -n --arg body "$UPDATED_COMMENT" '{"body": $body}')
curl -X PATCH \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"${COMMENT_URL}" \
-d "$PAYLOAD"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,61 @@
name: Image URL Processing
on:
issue_comment:
types: [created]
jobs:
process-image-url:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, 'https://github.com/github/release-assets/assets/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Extract and Clean Initial URL
id: extract-url
env:
BODY: ${{ github.event.comment.body }}
run: |
INITIAL_URL=$(echo "$BODY" | grep -o 'https://github.com/github/release-assets/assets/[^ >]*')
echo "Cleaned Initial URL: $INITIAL_URL"
echo "::set-output name=initial_url::$INITIAL_URL"
- name: Get Redirected URL with Debugging
id: curl
env:
INITIAL_URL: ${{ steps.extract-url.outputs.initial_url }}
run: |
REDIRECTED_URL=$(curl -L -o /dev/null -w %{url_effective} -sS "$INITIAL_URL")
echo "Curl Command Executed"
echo "Redirected URL: $REDIRECTED_URL"
echo "::set-output name=redirected_url::$REDIRECTED_URL"
- name: Trim URL after PNG
id: trim-url
env:
REDIRECTED_URL: ${{ steps.curl.outputs.redirected_url }}
run: |
TRIMMED_URL=$(echo "$REDIRECTED_URL" | sed 's/\(.*\.png\).*/\1/')
echo "Trimmed URL: $TRIMMED_URL"
echo "::set-output name=trimmed_url::$TRIMMED_URL"
- name: Output Final Trimmed URL
run: |
echo "Final Trimmed Image URL: ${{ steps.trim-url.outputs.trimmed_url }}"
- name: Update Comment with New URL
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENT_URL: ${{ github.event.comment.url }}
ORIGINAL_COMMENT_BODY: ${{ github.event.comment.body }}
run: |
NEW_COMMENT_BODY="Use this link to include this asset in your changelog: ${{ steps.trim-url.outputs.trimmed_url }}"
UPDATED_COMMENT="${ORIGINAL_COMMENT_BODY} 👀 ${NEW_COMMENT_BODY}"
PAYLOAD=$(jq -n --arg body "$UPDATED_COMMENT" '{"body": $body}')
curl -X PATCH \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"${COMMENT_URL}" \
-d "$PAYLOAD"

View File

@@ -0,0 +1,27 @@
name: Image URL Processing
on:
issue_comment:
types: [created]
jobs:
process-image-url:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, 'https://github.com/github/release-assets/assets/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Extract and Clean Initial URL
id: source
env:
BODY: ${{ github.event.comment.body }}
run: |
INITIAL_URL=$(echo "$BODY" | grep -o 'https://github.com/github/release-assets/assets/[^ >]*')
echo "Cleaned Initial URL: $INITIAL_URL"
echo "::set-output name=initial_url::$INITIAL_URL"
- name: Get Redirected URL with Debugging
id: sink
run: |
echo ${{ steps.source.outputs.initial_url }}