Merge commit from fork

This commit is contained in:
Lucas Saavedra Vaz 2024-09-15 20:15:24 -03:00 committed by GitHub
parent 9e60bbe4bc
commit a7cec020df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 5 deletions

View File

@ -41,6 +41,24 @@ jobs:
original_sha=$(cat ./artifacts/parent-artifacts/sha.txt) original_sha=$(cat ./artifacts/parent-artifacts/sha.txt)
original_ref=$(cat ./artifacts/parent-artifacts/ref.txt) original_ref=$(cat ./artifacts/parent-artifacts/ref.txt)
original_conclusion=$(cat ./artifacts/parent-artifacts/conclusion.txt) original_conclusion=$(cat ./artifacts/parent-artifacts/conclusion.txt)
# Sanitize the values to avoid security issues
# Event: Allow alphabetical characters and underscores
original_event=$(echo "$original_event" | tr -cd '[:alpha:]_')
# Action: Allow alphabetical characters and underscores
original_action=$(echo "$original_action" | tr -cd '[:alpha:]_')
# SHA: Allow alphanumeric characters
original_sha=$(echo "$original_sha" | tr -cd '[:alnum:]')
# Ref: Allow alphanumeric characters, slashes, underscores, dots, and dashes
original_ref=$(echo "$original_ref" | tr -cd '[:alnum:]/_.-')
# Conclusion: Allow alphabetical characters and underscores
original_conclusion=$(echo "$original_conclusion" | tr -cd '[:alpha:]_')
echo "original_event=$original_event" >> $GITHUB_ENV echo "original_event=$original_event" >> $GITHUB_ENV
echo "original_action=$original_action" >> $GITHUB_ENV echo "original_action=$original_action" >> $GITHUB_ENV
echo "original_sha=$original_sha" >> $GITHUB_ENV echo "original_sha=$original_sha" >> $GITHUB_ENV
@ -71,10 +89,10 @@ jobs:
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
const ref = '${{ env.original_ref }}'; const ref = process.env.original_ref;
const key_prefix = 'tests-' + ref + '-'; const key_prefix = 'tests-' + ref + '-';
if ('${{ env.original_event }}' == 'pull_request' && '${{ env.original_action }}' != 'closed') { if (process.env.original_event == 'pull_request' && process.env.original_action != 'closed') {
console.log('Skipping cache cleanup for open PR'); console.log('Skipping cache cleanup for open PR');
return; return;
} }
@ -104,12 +122,12 @@ jobs:
script: | script: |
const owner = '${{ github.repository_owner }}'; const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.split('/')[1]; const repo = '${{ github.repository }}'.split('/')[1];
const sha = '${{ env.original_sha }}'; const sha = process.env.original_sha;
core.debug(`owner: ${owner}`); core.debug(`owner: ${owner}`);
core.debug(`repo: ${repo}`); core.debug(`repo: ${repo}`);
core.debug(`sha: ${sha}`); core.debug(`sha: ${sha}`);
const { context: name, state } = (await github.rest.repos.createCommitStatus({ const { context: name, state } = (await github.rest.repos.createCommitStatus({
context: 'Runtime Tests / Report results (${{ env.original_event }} -> workflow_run -> workflow_run)', context: `Runtime Tests / Report results (${process.env.original_event} -> workflow_run -> workflow_run)`,
owner: owner, owner: owner,
repo: repo, repo: repo,
sha: sha, sha: sha,

View File

@ -6,18 +6,25 @@ on:
types: types:
- completed - completed
permissions:
contents: read
jobs: jobs:
upload_components: upload_components:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Get the release tag - name: Get the release tag
env:
head_branch: ${{ github.event.workflow_run.head_branch }}
run: | run: |
if [ "${{ github.event.workflow_run.conclusion }}" != "success" ]; then if [ "${{ github.event.workflow_run.conclusion }}" != "success" ]; then
echo "Release workflow failed. Exiting..." echo "Release workflow failed. Exiting..."
exit 1 exit 1
fi fi
branch=${{ github.event.workflow_run.head_branch }} # Read and sanitize the branch/tag name
branch=$(echo "$head_branch" | tr -cd '[:alnum:]/_.-')
if [[ $branch == refs/tags/* ]]; then if [[ $branch == refs/tags/* ]]; then
tag="${branch#refs/tags/}" tag="${branch#refs/tags/}"
elif [[ $branch =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then elif [[ $branch =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then