Skip to content

Update PR details #25343

Update PR details

Update PR details #25343

Workflow file for this run

## %CopyrightBegin%
##
## Copyright Ericsson AB 2024. All Rights Reserved.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## %CopyrightEnd%
name: Update PR details
# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ["Build and check Erlang/OTP"]
types:
- requested
- completed
# Limit concurrency so that we don't get any races between parallel actions
concurrency: pr-comment
permissions:
contents: read
jobs:
pr-number:
runs-on: ubuntu-20.04
if: github.repository == 'erlang/otp'
permissions:
issues: read
outputs:
result: ${{ steps.pr-number.outputs.result }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/[email protected]
- name: Fetch PR number
id: pr-number
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
git clone https://github.com/talentdeficit/jsx
(cd jsx && rebar3 compile)
.github/scripts/get-pr-number.es erlang/otp \
"${{ github.event.workflow_run.head_sha }}"
starting-tests:
runs-on: ubuntu-latest
needs: pr-number
permissions:
issues: write
pull-requests: write
if: github.event.action == 'requested' && needs.pr-number.outputs.result != ''
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/[email protected]
## We create an initial comment with some useful help to the user
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # ratchet:actions/[email protected]
with:
script: |
const script = require('./.github/scripts/pr-comment.js');
return await script({github, context, state: 'starting',
pr_number: ${{ needs.pr-number.outputs.result }} });
finished-tests:
runs-on: ubuntu-20.04
needs: pr-number
## Limit concurrency so that only one job deploys to erlang.github.io
concurrency: erlang.github.io-deploy
permissions:
issues: write
checks: write
pull-requests: write
if: >-
github.event.action == 'completed' &&
needs.pr-number.outputs.result != '' &&
github.event.workflow_run.conclusion != 'skipped'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/[email protected]
- name: Download and Extract Artifacts
id: extract
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir -p artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
gh api "$artifacts_url" --paginate -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
if [ "$name" = "Unit Test Results" ] || [ "$name" = "Event File" ]; then
gh api $url > "$name.zip"
unzip -d "$name" "$name.zip"
fi
done
if [ -d "Unit Test Results" ]; then
echo "HAS_TEST_ARTIFACTS=true" >> $GITHUB_OUTPUT
else
echo "HAS_TEST_ARTIFACTS=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/[email protected]
with:
token: ${{ secrets.ERLANG_TOKEN }}
repository: 'erlang/erlang.github.io'
path: erlang.github.io
- name: Publish CT Test Results
uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52403b73ed297e6645b # ratchet:EnricoMi/[email protected]
if: steps.extract.outputs.HAS_TEST_ARTIFACTS == 'true'
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
check_name: "CT Test Results"
files: "artifacts/**/*.xml"
- name: Upload PR to github pages
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
git clone https://github.com/talentdeficit/jsx
(cd jsx && rebar3 compile)
mkdir -p "${GITHUB_WORKSPACE}/erlang.github.io/prs/"
.github/scripts/sync-github-prs.es erlang/otp \
"${GITHUB_WORKSPACE}/erlang.github.io/prs/" \
"${{ needs.pr-number.outputs.result }}"
- name: Deploy to github pages 🚀
run: |
cd erlang.github.io
set -x
git config user.name github-actions
git config user.email [email protected]
git add .
git add -u
git update-index --refresh
if ! git diff-index --quiet HEAD --; then
git commit -m "Update github pages content"
git push origin master
fi
## Append some useful links and tips to the test results posted by
## Publish CT Test Results
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # ratchet:actions/[email protected]
if: always()
with:
script: |
const script = require('./.github/scripts/pr-comment.js');
return await script({github, context, state: 'finished',
pr_number: ${{ needs.pr-number.outputs.result }} });