File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,12 +20,20 @@ URL from which to fetch Nimbus experiments. Default: `https://experimenter.servi
2020
2121** Required** App name by which to filter experiments. Example: ` fenix `
2222
23+ ### ` branch `
24+
25+ ** Required** Remote branch to check diff against. Example: ` automation/update-nimbus-experiments `
26+
2327## Outputs
2428
2529### ` changed `
2630
2731The number of files that were modified as part of the script.
2832
33+ ### ` changed-branch `
34+
35+ The number of files that were modified as compared to the supplied remote branch.
36+
2937## Example usage
3038
3139``` yaml
3442 repo-path : main
3543 output-path : app/src/main/res/raw/initial_experiments.json
3644 experimenter-url : https://experimenter.services.mozilla.com/api/v6/experiments/
45+ branch : automation/update-nimbus-experiments
3746` ` `
Original file line number Diff line number Diff line change @@ -14,14 +14,20 @@ inputs:
1414 app-name :
1515 description : ' App name by which to filter experiments'
1616 required : true
17+ branch :
18+ description : ' Remote branch to check diff against'
19+ required : true
1720outputs :
1821 changed :
1922 description : ' The number of files that were modified as part of the script'
23+ changed-branch :
24+ description : ' The number of files that were modified as compared to the supplied remote branch'
2025runs :
2126 using : ' docker'
2227 image : ' Dockerfile'
2328 args :
2429 - ${{ inputs.repo-path }}
2530 - ${{ inputs.output-path }}
2631 - ${{ inputs.experimenter-url }}
27- - ${{ inputs.app-name }}
32+ - ${{ inputs.app-name }}
33+ - ${{ inputs.branch }}
Original file line number Diff line number Diff line change 1- #! /bin/sh -l
1+ #! /bin/bash
22
33git config --global --add safe.directory " /github/workspace/$1 "
44
@@ -7,12 +7,30 @@ curl $3 | jq --arg APP_NAME "$4" '{"data":map(select(.appName == $APP_NAME))}' >
77
88git status
99export CHANGED=$( git status -s | wc -l)
10+ export CHANGED_BRANCH=0
1011
1112if test $CHANGED -eq 1
1213then
13- git add $2
14- echo " $CHANGED file(s) have been modified"
14+ git add $2
15+ echo " $CHANGED file(s) have been modified"
16+
17+ export REMOTE_BRANCH=$( git ls-remote --head origin $5 )
18+ if [[ -z $REMOTE_BRANCH ]];
19+ then
20+ export CHANGED_BRANCH=1
21+ echo " Remote branch currently does not exist; outputting that there are changes."
22+ else
23+ export CHANGED_BRANCH=$( git --no-pager diff origin/$5 | grep $2 | wc -l)
24+ if test $CHANGED_BRANCH -eq 1
25+ then
26+ echo " Remote branch differs from current changes, it should be updated."
27+ else
28+ echo " Remote branch and current changes are equivalent."
29+ fi
30+ fi
1531else
16- echo " No changes to make, exiting job"
32+ echo " No changes to make, exiting job"
1733fi
34+
1835echo " ::set-output name=changed::$CHANGED "
36+ echo " ::set-output name=changed-branch::$CHANGED_BRANCH "
You can’t perform that action at this time.
0 commit comments