-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (71 loc) · 2.86 KB
/
updload_artifacts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Upload-Artifacts
on:
workflow_run:
workflows: [Blockifier-CI-Test]
types: [completed]
jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: set env vars
# if: github.event.workflow_run.pull_requests != ''
run: |
echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
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
echo "The workflow run URL is: $GITHUB_RUN_URL"
- name: Add a comment to the PR
if: env.PR_NUMBER != '' && env.WORKFLOW_LINK != ''
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})`
})
- name: Commit hash - 1
# if: ${{ github.event_name == 'pull_request' }}
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
- uses: actions/checkout@v4
with:
ref: ${{ env.COMMIT_SHA }}
- name: Verify current branch
run: git branch --show-current
- name: the workflow run URL
run: |
echo "The workflow run URL is: ${{ env.GITHUB_RUN_URL }}"
echo "The workflow run GITHUB_API_URL is: ${{ env.GITHUB_API_URL}}"
echo "*******"
echo "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
echo "*******"
echo "The workflow run number is: ${{ github.run_number }}"
echo "The workflow run name is: ${{ github.run_id }}"
- name: Checkout repository
uses: actions/checkout@v3
- name: Authenticate with GCS
uses: "google-github-actions/auth@v2"
with:
credentials_json: ${{ secrets.NADIN_TEST_FORK_BUCKET_ACCESS_KEY }}
- name: ls
run: ls
- name: Upload binary to GCP
id: upload_file
uses: "google-github-actions/upload-cloud-storage@v2"
with:
path: "upload_to_gcp.txt"
destination: "nadin-test-fork/${{ env.SHORT_HASH }}/"
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'