Skip to content

Commit

Permalink
PTFE 1271 backport (#400)
Browse files Browse the repository at this point in the history
- 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] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
tcarmet and dependabot[bot] authored Dec 22, 2023
1 parent ac36018 commit 69b965a
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
name: test-index

concurrency:
group: ${{ github.workflow }}
group: ${{ github.workflow }}-${{ github.ref_name }}

jobs:
setup:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/test-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
on: pull_request

name: Test pull request

jobs:
tests:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: create file to upload
run: |
mkdir -p artifacts
echo "Hello world" > artifacts/file1.txt
- name: Push all files
uses: ./
id: artifacts
with:
url: ${{ vars.ARTIFACTS_URL }}
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: ./artifacts
method: upload
- name: Test results
run: |
SHA=${{ github.event.pull_request.head.sha }}
SHORTSHA=${SHA::10}
# We expect SHORTSHA to be in the name of the artifact
if [[ ${ARTIFACTS_NAME} != *${SHORTSHA}* ]]; then
echo "Artifact name ${ARTIFACT_NAME} does not contain the short SHA"
exit 1
fi
env:
ARTIFACTS_NAME: ${{ steps.artifacts.outputs.name }}
134 changes: 111 additions & 23 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.0",
"@actions/github": "5.0.0",
"@actions/glob": "^0.2.0",
"@actions/glob": "^0.4.0",
"@octokit/rest": "^18.12.0",
"@octokit/types": "^6.34.0",
"@octokit/types": "^12.4.0",
"@types/async": "^3.2.12",
"async": "^3.2.3",
"axios": "^0.24.0",
"isomorphic-git": "^1.21.0"
"isomorphic-git": "^1.25.1"
},
"devDependencies": {
"@types/node": "^16.10.5",
Expand Down
19 changes: 12 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ export function artifactsRetry(
export async function getCommitSha1(revspec: string): Promise<string> {
let sha = ''
try {
const commits = await git.log({
fs,
dir: process.cwd(),
ref: revspec,
depth: 1
})
sha = commits[0].oid
if (context.eventName === 'pull_request') {
sha = context.payload.pull_request?.head?.sha as string
}
else {
const commits = await git.log({
fs,
dir: process.cwd(),
ref: revspec,
depth: 1
})
sha = commits[0].oid
}
} catch (e) {
core.debug('getCommitSha1 failed, fallback to context.sha')
sha = context.sha
Expand Down
Loading

0 comments on commit 69b965a

Please sign in to comment.