Skip to content

Commit 69b965a

Browse files
PTFE 1271 backport (#400)
- Update concurrency group index-tests - npm(deps): bump isomorphic-git from 1.24.5 to 1.25.1 (#382) - npm(deps): bump @octokit/types from 6.41.0 to 12.4.0 (#379) - npm(deps): bump @actions/glob from 0.2.1 to 0.4.0 (#362) - PTFE-1271 handle proper sha on pull_request events --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent ac36018 commit 69b965a

File tree

7 files changed

+186
-46
lines changed

7 files changed

+186
-46
lines changed

.github/workflows/test-index.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
name: test-index
1414

1515
concurrency:
16-
group: ${{ github.workflow }}
16+
group: ${{ github.workflow }}-${{ github.ref_name }}
1717

1818
jobs:
1919
setup:
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
on: pull_request
3+
4+
name: Test pull request
5+
6+
jobs:
7+
tests:
8+
runs-on: ubuntu-latest
9+
environment: production
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: create file to upload
13+
run: |
14+
mkdir -p artifacts
15+
echo "Hello world" > artifacts/file1.txt
16+
- name: Push all files
17+
uses: ./
18+
id: artifacts
19+
with:
20+
url: ${{ vars.ARTIFACTS_URL }}
21+
user: ${{ secrets.ARTIFACTS_USER }}
22+
password: ${{ secrets.ARTIFACTS_PASSWORD }}
23+
source: ./artifacts
24+
method: upload
25+
- name: Test results
26+
run: |
27+
SHA=${{ github.event.pull_request.head.sha }}
28+
SHORTSHA=${SHA::10}
29+
# We expect SHORTSHA to be in the name of the artifact
30+
if [[ ${ARTIFACTS_NAME} != *${SHORTSHA}* ]]; then
31+
echo "Artifact name ${ARTIFACT_NAME} does not contain the short SHA"
32+
exit 1
33+
fi
34+
env:
35+
ARTIFACTS_NAME: ${{ steps.artifacts.outputs.name }}

dist/index.js

Lines changed: 111 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
"@actions/core": "^1.10.0",
2929
"@actions/exec": "^1.1.0",
3030
"@actions/github": "5.0.0",
31-
"@actions/glob": "^0.2.0",
31+
"@actions/glob": "^0.4.0",
3232
"@octokit/rest": "^18.12.0",
33-
"@octokit/types": "^6.34.0",
33+
"@octokit/types": "^12.4.0",
3434
"@types/async": "^3.2.12",
3535
"async": "^3.2.3",
3636
"axios": "^0.24.0",
37-
"isomorphic-git": "^1.21.0"
37+
"isomorphic-git": "^1.25.1"
3838
},
3939
"devDependencies": {
4040
"@types/node": "^16.10.5",

src/utils.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ export function artifactsRetry(
7575
export async function getCommitSha1(revspec: string): Promise<string> {
7676
let sha = ''
7777
try {
78-
const commits = await git.log({
79-
fs,
80-
dir: process.cwd(),
81-
ref: revspec,
82-
depth: 1
83-
})
84-
sha = commits[0].oid
78+
if (context.eventName === 'pull_request') {
79+
sha = context.payload.pull_request?.head?.sha as string
80+
}
81+
else {
82+
const commits = await git.log({
83+
fs,
84+
dir: process.cwd(),
85+
ref: revspec,
86+
depth: 1
87+
})
88+
sha = commits[0].oid
89+
}
8590
} catch (e) {
8691
core.debug('getCommitSha1 failed, fallback to context.sha')
8792
sha = context.sha

0 commit comments

Comments
 (0)