Skip to content

Commit

Permalink
Change artifact upload to reference github commit sha instead of pr n…
Browse files Browse the repository at this point in the history
…umber

The github sha would be a better version number to use than the PR number,
as its immutable and follows best practices. Also eliminates unnecessary
junk in the workflow to make it work with both PRs and pushes/merges
  • Loading branch information
pputman-clabs committed Dec 22, 2024
1 parent fbfce1e commit e494b16
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions .github/workflows/protocol-devchain-anvil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,6 @@ jobs:
path: ./out
key: ${{ runner.os }}-foundry-out-${{ env.FOUNDRY_CACHE_KEY }}

- name: Display SHA
run: |
echo "SHA: ${{ github.sha }}"
- name: Get Pull Request data
id: get_pr_data
uses: actions/github-script@v7
with:
script: |
const result = (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0];
core.setOutput("number", result ? result.number : "");
- name: Set PR Number
id: set_pr_number
run: |
if [ -z "${{ steps.get_pr_data.outputs.number }}" ]; then
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
else
echo "PR_NUMBER=${{ steps.get_pr_data.outputs.number }}" >> $GITHUB_ENV
fi
- name: Display PR Number
run: |
echo "Pull Request Number: ${{ env.PR_NUMBER }}"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773
with:
Expand Down Expand Up @@ -167,7 +136,7 @@ jobs:
- name: Upload devchain as artifact
uses: actions/upload-artifact@v4
with:
name: devchain-${{ env.PR_NUMBER }}-${{ steps.date.outputs.date }}
name: devchain-${{ github.sha }}-${{ steps.date.outputs.date }}
path: packages/protocol/.tmp
# Max retention time is 90 days for public repos
# https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy
Expand Down

0 comments on commit e494b16

Please sign in to comment.