Update artifacts list #146
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update artifacts list | |
on: | |
workflow_run: | |
types: | |
- completed | |
workflows: | |
- 'Creating plugin package in main branch' | |
jobs: | |
comment: | |
if: github.event.workflow_run.conclusion == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download workflow artifact | |
uses: dawidd6/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
workflow: peek_icons.yml | |
run_id: ${{ github.event.workflow_run.id }} | |
- name: Read the zip file name | |
id: zip_file_name_reader | |
uses: juliangruber/[email protected] | |
with: | |
path: ./zip_file_name/zip_file_name.txt | |
- name: Get artifact and push event info | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }} | |
OWNER: ${{ github.repository_owner }} | |
REPO: ${{ github.event.repository.name }} | |
ZIP_FILENAME: ${{ steps.zip_file_name_reader.outputs.content }} | |
run: | | |
PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ") | |
echo "Previous Job ID: $PREVIOUS_JOB_ID" | |
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV" | |
SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ") | |
echo "Previous Suite ID: $SUITE_ID" | |
echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV" | |
echo "ARTIFACT_NAME=$ZIP_FILENAME" >> "$GITHUB_ENV" | |
ARTIFACT_IDS=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \ | |
--jq [".artifacts.[] | | |
select(.workflow_run.id==$PREVIOUS_JOB_ID) | | |
select(.expired==false) | {id, name}"] | |
) | |
echo "ARTIFACT_IDS=$ARTIFACT_IDS" >> "$GITHUB_ENV" | |
echo "Head SHA: ${{ github.event.head_sha }}" | |
- name: Get upload zip artifact id | |
run: | | |
echo "ARTIFACT_ID=$(python -c "import os, json; | |
[print(str(art['id'])) for art in json.loads( | |
os.getenv('ARTIFACT_IDS').replace('\'', '\"')) | |
if art['name'] == os.getenv('ARTIFACT_NAME') ]")" >> "$GITHUB_ENV" | |
echo "The ARTIFACT ID: $ARTIFACT_ID" | |
- name: Save the public artifact URL into an artifact | |
shell: bash | |
env: | |
ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}" | |
run: | | |
echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
ref: docs | |
- name: Update the documentation | |
run: | | |
echo "$ARTIFACT_NAME - $ARTIFACT_URL" >> docs/admin/artifacts_list.txt | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global --add safe.directory /__w/cplus-plugin/cplus-plugin | |
git add -A | |
git commit -m "Update on the artifact_list.txt" | |
git push origin docs |