Skip to content

Commit 1708e0f

Browse files
author
Alvaro Muñoz
committed
Move tests files to .github/workflows
1 parent da2ac2a commit 1708e0f

File tree

12 files changed

+190
-0
lines changed

12 files changed

+190
-0
lines changed
File renamed without changes.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
run-name: Cleanup ${{ github.head_ref }}
2+
on:
3+
pull_request_target:
4+
types: labeled
5+
paths:
6+
- "images/**"
7+
8+
jobs:
9+
clean_ci:
10+
name: Clean CI runs
11+
runs-on: ubuntu-latest
12+
permissions:
13+
actions: write
14+
steps:
15+
- env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
shell: pwsh
18+
run: |
19+
$startDate = Get-Date -UFormat %s
20+
$workflows = @("macos11", "macos12", "ubuntu2004", "ubuntu2204", "windows2019", "windows2022")
21+
while ($true) {
22+
$continue = $false
23+
foreach ($wf in $workflows) {
24+
$skippedCommand = "gh run list --workflow ${wf}.yml --branch ${{ github.event.pull_request.head.ref }} --repo ${{ github.repository }} --status skipped --json databaseId"
25+
$skippedIds = Invoke-Expression -Command $skippedCommand | ConvertFrom-Json | ForEach-Object { $_.databaseId }
26+
$skippedIds | ForEach-Object {
27+
$deleteCommand = "gh run delete --repo ${{ github.repository }} $_"
28+
Invoke-Expression -Command $deleteCommand
29+
}
30+
$pendingCommand = "gh run list --workflow ${wf}.yml --branch ${{ github.event.pull_request.head.ref }} --repo ${{ github.repository }} --status requested --json databaseId --template '{{ . | len }}'"
31+
$pending = Invoke-Expression -Command $pendingCommand
32+
if ($pending -gt 0) {
33+
Write-Host "Pending for ${wf}.yml: $pending run(s)"
34+
$continue = $true
35+
}
36+
}
37+
if ($continue -eq $false) {
38+
Write-Host "All done, exiting"
39+
break
40+
}
41+
$curDate = Get-Date -UFormat %s
42+
if (($curDate - $startDate) -gt 60) {
43+
Write-Host "Reached timeout, exiting"
44+
break
45+
}
46+
Write-Host "Waiting 5 seconds..."
47+
Start-Sleep -Seconds 5
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Image URL Processing
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
process-image-url:
9+
runs-on: ubuntu-latest
10+
if: contains(github.event.comment.body, 'https://github.com/github/release-assets/assets/')
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Extract and Clean Initial URL
16+
id: extract-url
17+
run: |
18+
INITIAL_URL=$(echo "${{ github.event.comment.body }}" | grep -o 'https://github.com/github/release-assets/assets/[^ >]*')
19+
echo "Cleaned Initial URL: $INITIAL_URL"
20+
echo "::set-output name=initial_url::$INITIAL_URL"
21+
22+
- name: Get Redirected URL with Debugging
23+
id: curl
24+
run: |
25+
REDIRECTED_URL=$(curl -L -o /dev/null -w %{url_effective} -sS "${{ steps.extract-url.outputs.initial_url }}")
26+
echo "Curl Command Executed"
27+
echo "Redirected URL: $REDIRECTED_URL"
28+
echo "::set-output name=redirected_url::$REDIRECTED_URL"
29+
30+
- name: Trim URL after PNG
31+
id: trim-url
32+
run: |
33+
TRIMMED_URL=$(echo "${{ steps.curl.outputs.redirected_url }}" | sed 's/\(.*\.png\).*/\1/')
34+
echo "Trimmed URL: $TRIMMED_URL"
35+
echo "::set-output name=trimmed_url::$TRIMMED_URL"
36+
37+
- name: Output Final Trimmed URL
38+
run: |
39+
echo "Final Trimmed Image URL: ${{ steps.trim-url.outputs.trimmed_url }}"
40+
41+
- name: Update Comment with New URL
42+
run: |
43+
COMMENT_URL="${{ github.event.comment.url }}"
44+
NEW_COMMENT_BODY="Use this link to include this asset in your changelog: ${{ steps.trim-url.outputs.trimmed_url }}"
45+
ORIGINAL_COMMENT_BODY="${{ github.event.comment.body }}"
46+
UPDATED_COMMENT="${ORIGINAL_COMMENT_BODY} 👀 ${NEW_COMMENT_BODY}"
47+
48+
PAYLOAD=$(jq -n --arg body "$UPDATED_COMMENT" '{"body": $body}')
49+
curl -X PATCH \
50+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
51+
-H "Accept: application/vnd.github.v3+json" \
52+
"${COMMENT_URL}" \
53+
-d "$PAYLOAD"
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Image URL Processing
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
process-image-url:
9+
runs-on: ubuntu-latest
10+
if: contains(github.event.comment.body, 'https://github.com/github/release-assets/assets/')
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Extract and Clean Initial URL
16+
id: extract-url
17+
env:
18+
BODY: ${{ github.event.comment.body }}
19+
run: |
20+
INITIAL_URL=$(echo "$BODY" | grep -o 'https://github.com/github/release-assets/assets/[^ >]*')
21+
echo "Cleaned Initial URL: $INITIAL_URL"
22+
echo "::set-output name=initial_url::$INITIAL_URL"
23+
24+
- name: Get Redirected URL with Debugging
25+
id: curl
26+
env:
27+
INITIAL_URL: ${{ steps.extract-url.outputs.initial_url }}
28+
run: |
29+
REDIRECTED_URL=$(curl -L -o /dev/null -w %{url_effective} -sS "$INITIAL_URL")
30+
echo "Curl Command Executed"
31+
echo "Redirected URL: $REDIRECTED_URL"
32+
echo "::set-output name=redirected_url::$REDIRECTED_URL"
33+
34+
- name: Trim URL after PNG
35+
id: trim-url
36+
env:
37+
REDIRECTED_URL: ${{ steps.curl.outputs.redirected_url }}
38+
run: |
39+
TRIMMED_URL=$(echo "$REDIRECTED_URL" | sed 's/\(.*\.png\).*/\1/')
40+
echo "Trimmed URL: $TRIMMED_URL"
41+
echo "::set-output name=trimmed_url::$TRIMMED_URL"
42+
43+
- name: Output Final Trimmed URL
44+
run: |
45+
echo "Final Trimmed Image URL: ${{ steps.trim-url.outputs.trimmed_url }}"
46+
47+
- name: Update Comment with New URL
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
COMMENT_URL: ${{ github.event.comment.url }}
51+
ORIGINAL_COMMENT_BODY: ${{ github.event.comment.body }}
52+
run: |
53+
NEW_COMMENT_BODY="Use this link to include this asset in your changelog: ${{ steps.trim-url.outputs.trimmed_url }}"
54+
UPDATED_COMMENT="${ORIGINAL_COMMENT_BODY} 👀 ${NEW_COMMENT_BODY}"
55+
56+
PAYLOAD=$(jq -n --arg body "$UPDATED_COMMENT" '{"body": $body}')
57+
curl -X PATCH \
58+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
59+
-H "Accept: application/vnd.github.v3+json" \
60+
"${COMMENT_URL}" \
61+
-d "$PAYLOAD"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Image URL Processing
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
process-image-url:
9+
runs-on: ubuntu-latest
10+
if: contains(github.event.comment.body, 'https://github.com/github/release-assets/assets/')
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Extract and Clean Initial URL
16+
id: source
17+
env:
18+
BODY: ${{ github.event.comment.body }}
19+
run: |
20+
INITIAL_URL=$(echo "$BODY" | grep -o 'https://github.com/github/release-assets/assets/[^ >]*')
21+
echo "Cleaned Initial URL: $INITIAL_URL"
22+
echo "::set-output name=initial_url::$INITIAL_URL"
23+
24+
- name: Get Redirected URL with Debugging
25+
id: sink
26+
run: |
27+
echo ${{ steps.source.outputs.initial_url }}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)