Skip to content

Commit d3c5b03

Browse files
authored
Merge pull request #794 from ProgramEquity/Dunridge-patch-3
fix
2 parents d23fab9 + b6d2698 commit d3c5b03

File tree

6 files changed

+27
-33
lines changed

6 files changed

+27
-33
lines changed

.github/workflows/issue-metrics.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: |
2424
current_branch=$(git rev-parse --abbrev-ref HEAD)
2525
echo "Currently checked out branch: $current_branch"
26-
26+
2727
- name: Add Issue Timestamp To File
2828
working-directory: roiScript
2929
run: |
@@ -37,4 +37,4 @@ jobs:
3737
git config --global user.name "Dunridge"
3838
git add .
3939
git commit -m "Add issue timestamp by $GITHUB_ACTOR"
40-
git push https://${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git
40+
git push https://${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git

.github/workflows/pr-metrics.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ on:
77
jobs:
88
record_pr_timestamp:
99
runs-on: ubuntu-latest
10-
if: github.event_name == 'pull_request'
11-
outputs:
12-
pr_timestamp: ${{ steps.get_pr_timestamp.outputs.pr_timestamp }}
10+
if: github.event_name == 'pull_request'
11+
outputs:
12+
pr_timestamp: ${{ steps.get_pr_timestamp.outputs.pr_timestamp }}
1313
steps:
1414
- name: Get Current Timestamp for PR
1515
id: get_pr_timestamp
16-
run: |
16+
run: |
1717
current_timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
1818
seconds_since_epoch=$(date -d "${current_timestamp}" +%s)
1919
echo "PR timestamp: ${current_timestamp}"
@@ -23,8 +23,8 @@ jobs:
2323
get_issue_timestamp:
2424
needs: record_pr_timestamp
2525
runs-on: ubuntu-latest
26-
outputs:
27-
issue_timestamp: ${{ steps.get_issue_timestamp.outputs.issue_timestamp }}
26+
outputs:
27+
issue_timestamp: ${{ steps.get_issue_timestamp.outputs.issue_timestamp }}
2828
steps:
2929
- name: Checkout the repository
3030
uses: actions/checkout@v2
@@ -34,38 +34,38 @@ jobs:
3434
git fetch
3535
echo "Current Branch: $(git branch)"
3636
git checkout ${{github.event.pull_request.head.ref}}
37-
38-
- name: Get Issue Timestamp
39-
id: get_issue_timestamp
37+
38+
- name: Get Issue Timestamp
39+
id: get_issue_timestamp
4040
working-directory: roiScript
41-
run: | # timestamp: Dunridge, issue #767: 2023-11-14 16:06:02
41+
run: | # timestamp: Dunridge, issue #767: 2023-11-14 16:06:02
4242
issue_timestamp=$(cat issue_timestamp.log | awk -F ': ' '{print $2}')
4343
seconds_since_epoch=$(date -d "${issue_timestamp}" +"%s")
4444
echo "Issue timestamp from the first step: ${issue_timestamp}"
4545
echo "Issue timestamp in seconds: ${seconds_since_epoch}"
4646
echo "::set-output name=issue_timestamp::${seconds_since_epoch}"
4747
echo "" > issue_timestamp.log
48-
49-
- name: Commit Timestamp Removal # step + echo "" > issue_timestamp.log -- for clearing the issue_timestamp.log file so that this doesn't run on second reviewer assignment
48+
49+
- name: Commit Timestamp Removal # step + echo "" > issue_timestamp.log -- for clearing the issue_timestamp.log file so that this doesn't run on second reviewer assignment
5050
run: |
5151
git config --global user.email "[email protected]"
5252
git config --global user.name "Dunridge"
5353
git add .
5454
git commit -m "Remove issue timestamp by $GITHUB_ACTOR"
55-
git push https://${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git
55+
git push https://${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git
5656
5757
calculate_time_difference:
58-
needs:
58+
needs:
5959
- record_pr_timestamp
6060
- get_issue_timestamp
6161
runs-on: ubuntu-latest
62-
outputs:
62+
outputs:
6363
time_diff: ${{ steps.time_difference.outputs.time_diff }}
64-
env:
64+
env:
6565
pr_timestamp_input: ${{needs.record_pr_timestamp.outputs.pr_timestamp}}
6666
issue_timestamp_input: ${{needs.get_issue_timestamp.outputs.issue_timestamp}}
6767
steps:
68-
- name: Calculate Time Difference
68+
- name: Calculate Time Difference
6969
id: time_difference
7070
run: |
7171
issue_timestamp=$issue_timestamp_input
@@ -79,7 +79,7 @@ jobs:
7979
metric:
8080
needs: calculate_time_difference
8181
runs-on: ubuntu-latest
82-
env:
82+
env:
8383
time_diff_input: ${{needs.calculate_time_difference.outputs.time_diff}}
8484
steps:
8585
- name: Checkout code
@@ -101,6 +101,6 @@ jobs:
101101
- name: Run
102102
env:
103103
GH_TOKEN: ${{ secrets.GH_TOKEN }}
104-
TIME_DIFF: ${{ needs.calculate_time_difference.outputs.time_diff }}
104+
TIME_DIFF: ${{ needs.calculate_time_difference.outputs.time_diff }}
105105
PR_NUMBER: ${{ github.event.number }}
106106
run: node ./roiScript/issue-metrics.mjs

roiScript/issue-metrics.mjs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
console.log('test') // works
2-
3-
import * as core from '@actions/core'
41
import github from '@actions/github'
52

6-
const pullNumber = process.env.PR_NUMBER; //779; // TODO: pass the PR number from the workflow file
7-
console.log('pullNumber', pullNumber);
8-
const timeDiff = process.env.TIME_DIFF ? process.env.TIME_DIFF : 1;
9-
const comment = `Time from assignment to PR for #${pullNumber}: ${timeDiff} ms`;
3+
const pullNumber = process.env.PR_NUMBER
4+
const timeDiff = process.env.TIME_DIFF ? process.env.TIME_DIFF : 1
5+
const comment = `Time from assignment to PR for #${pullNumber}: ${timeDiff} ms`
106

11-
const octokit = github.getOctokit(process.env.GH_TOKEN);
7+
const octokit = github.getOctokit(process.env.GH_TOKEN)
128

139
await octokit.rest.issues.createComment({
1410
owner: github.context.repo.owner,
1511
repo: github.context.repo.repo,
1612
issue_number: pullNumber,
1713
body: comment
18-
});
14+
})

roiScript/issue_timestamp.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Dunridge, issue #783: 2023-11-15 18:06:23
1+

roiScript/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"node": "16.x"
2020
},
2121
"dependencies": {
22-
"@actions/core": "^1.10.1",
2322
"@actions/github": "^6.0.0"
2423
}
2524
}

roiScript/pr_timestamp.log

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)