Skip to content

Upload-Artifacts

Upload-Artifacts #3327

name: Upload-Artifacts
on:
workflow_run:
workflows: [Trigger-Workflow]
types: [completed]
jobs:
native-blockifier-artifacts-push:
runs-on: starkware-ubuntu-20-04-medium
steps:
- name: Get commit hash prefix for PR update
env:
COMMIT_SHA: ${{ github.event.workflow_run.head_commit.id }}
run: |
echo "SHORT_HASH=${COMMIT_SHA:0:7}" >> $GITHUB_ENV
echo "COMMIT_SHA=${COMMIT_SHA}" >> $GITHUB_ENV
# This workflow is always triggered in `main` branch context, so need to checkout the commit.
- uses: actions/checkout@v4
with:
ref: ${{ env.COMMIT_SHA }}
# Set environment variables.
- name: Set environment variable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr_number=$(gh pr list --head "${{ github.event.workflow_run.head_branch }}" --json number --jq '.[0].number')
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
echo "WORKFLOW_LINK=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
- name: Add a comment to the PR
if: env.PR_NUMBER != ''
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const workflowLink = process.env.WORKFLOW_LINK;
github.rest.issues.createComment({
issue_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Artifacts upload triggered. [View details here](${workflowLink})`
})
- uses: ./.github/actions/bootstrap
- name: Build native blockifier
run: ./build_native_in_docker.sh scripts/build_native_blockifier.sh
# Rename is required; see https://pyo3.rs/v0.19.2/building_and_distribution#manual-builds.
- name: Rename shared object
run: |
mv \
target/release/libnative_blockifier.so \
target/release/native_blockifier.pypy39-pp73-x86_64-linux-gnu.so
- name: Authenticate with GCS
uses: "google-github-actions/auth@v2"
with:
credentials_json: ${{ secrets.SA_NATIVE_BLOCKIFIER_ARTIFACTS_BUCKET_WRITER_ACCESS_KEY }}
- name: Upload binary to GCP
id: upload_file
uses: "google-github-actions/upload-cloud-storage@v2"
with:
path: "target/release/native_blockifier.pypy39-pp73-x86_64-linux-gnu.so"
destination: "native_blockifier_artifacts/${{ env.SHORT_HASH }}/release/"