Skip to content

Commit

Permalink
Upload tmp.log (will eventually exist) and only create url files if t…
Browse files Browse the repository at this point in the history
…he steps succeeded
  • Loading branch information
JasonGross committed Jan 11, 2024
1 parent 0641b92 commit 6907d27
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ jobs:
path: tmp.v
if: always()

- name: Upload temp log file
id: upload-tmp-log
uses: actions/upload-artifact@v4
with:
name: tmp.log
path: tmp.log
if: always()

- name: Upload metadata file
id: upload-metadata
uses: actions/upload-artifact@v4
Expand All @@ -80,19 +88,13 @@ jobs:
- name: Stamp file links
run: |
set -x
printf '%s\n' "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/artifacts/${{ steps.upload-bug-v.outputs.artifact-id }}/zip" | tee bug.v.api.url
printf '%s\n' "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/artifacts/${{ steps.upload-bug-log.outputs.artifact-id }}/zip" | tee bug.log.api.url
printf '%s\n' "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/artifacts/${{ steps.upload-bug-verbose-log.outputs.artifact-id }}/zip" | tee bug.verbose.log.api.url
printf '%s\n' "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/artifacts/${{ steps.upload-build-log.outputs.artifact-id }}/zip" | tee build.log.api.url
printf '%s\n' "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/artifacts/${{ steps.upload-tmp-v.outputs.artifact-id }}/zip" | tee tmp.v.api.url
printf '%s\n' "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/artifacts/${{ steps.upload-metadata.outputs.artifact-id }}/zip" | tee metadata.api.url
printf '%s\n' "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts/${{ steps.upload-bug-v.outputs.artifact-id }}" | tee bug.v.url
printf '%s\n' "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts/${{ steps.upload-bug-log.outputs.artifact-id }}" | tee bug.log.url
printf '%s\n' "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts/${{ steps.upload-bug-verbose-log.outputs.artifact-id }}" | tee bug.verbose.log.url
printf '%s\n' "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts/${{ steps.upload-build-log.outputs.artifact-id }}" | tee build.log.url
printf '%s\n' "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts/${{ steps.upload-tmp-v.outputs.artifact-id }}" | tee tmp.v.url
printf '%s\n' "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts/${{ steps.upload-metadata.outputs.artifact-id }}" | tee metadata.url
./stamp-artifact-url.sh bug.v "${{ steps.upload-bug-v.outputs.artifact-id }}" "${{ steps.upload-bug-v.outcome }}"
./stamp-artifact-url.sh bug.log "${{ steps.upload-bug-log.outputs.artifact-id }}" "${{ steps.upload-bug-log.outcome }}"
./stamp-artifact-url.sh bug.verbose.log "${{ steps.upload-bug-verbose-log.outputs.artifact-id }}" "${{ steps.upload-bug-verbose-log.outcome }}"
./stamp-artifact-url.sh build.log "${{ steps.upload-build-log.outputs.artifact-id }}" "${{ steps.upload-build-log.outcome }}"
./stamp-artifact-url.sh tmp.v "${{ steps.upload-tmp-v.outputs.artifact-id }}" "${{ steps.upload-tmp-v.outcome }}"
./stamp-artifact-url.sh tmp.log "${{ steps.upload-tmp-log.outputs.artifact-id }}" "${{ steps.upload-tmp-log.outcome }}"
./stamp-artifact-url.sh metadata "${{ steps.upload-metadata.outputs.artifact-id }}" "${{ steps.upload-metadata.outcome }}"
if: always()

- name: Reply via coqbot
Expand Down
21 changes: 21 additions & 0 deletions stamp-artifact-url.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

function usage() {
printf 'USAGE: %q FILE_NAME ARTIFACT_ID OUTCOME\n' "$0"
# outcome should be success, failure, cancelled, or skipped, cf https://stackoverflow.com/a/70549615/377022
exit 1
}

if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
usage
fi

filename="$1"
artifact_id="$2"
outcome="$3"
if [ "${outcome}" == "success" ]; then
printf '%s' "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/artifacts/${artifact_id}/zip" | tee "${filename}.api.url"
echo
printf '%s' "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts/${artifact_id}" | tee "${filename}.url"
echo
fi

0 comments on commit 6907d27

Please sign in to comment.