Skip to content

Commit

Permalink
Testing secret
Browse files Browse the repository at this point in the history
  • Loading branch information
ribalba committed Apr 8, 2024
1 parent 9be75a5 commit 41b731b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ runs:
id: run-total-model
shell: bash
run: |
${{github.action_path}}/scripts/display_results.sh -dt ${{inputs.display-table}} -dg ${{inputs.display-graph}} -db ${{inputs.display-badge}} -b "${{inputs.branch}}" -r ${{ github.run_id }} -R "${{ github.repository }}" -sd ${{inputs.send-data}} -sc ${{inputs.show-carbon}} -s "github"
${{github.action_path}}/scripts/display_results.sh -dt ${{inputs.display-table}} -dg ${{inputs.display-graph}} -db ${{inputs.display-badge}} -b "${{inputs.branch}}" -r ${{ github.run_id }} -R "${{ github.repository }}" -sd ${{inputs.send-data}} -sc ${{inputs.show-carbon}} -s "github" -emt "${{secrets.electricity_maps_token}}"
cat "/tmp/eco-ci/output.txt" >> $GITHUB_STEP_SUMMARY
total_data_file="/tmp/eco-ci/total-data.json"
echo "data-total-json=$(cat $total_data_file)" >> $GITHUB_OUTPUT
Expand Down
10 changes: 8 additions & 2 deletions scripts/display_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function display_results {
branch_enc=$( echo ${branch} | jq -Rr @uri)

if [[ ${show_carbon} == 'true' ]]; then
source "$(dirname "$0")/vars.sh" get_co2 "$total_energy"
source "$(dirname "$0")/vars.sh" get_co2 "$total_energy" "$electricity_maps_token"
if [ -n "$CO2EQ" ]; then # We only check for co2 as if this is set the others should be set too
echo '🌳 CO2 Data:' | tee -a $output $output_pr
echo "City: $CITY, Lat: $LAT, Lon: $LON" | tee -a $output $output_pr
Expand Down Expand Up @@ -171,6 +171,7 @@ display_graph=""
send_data=""
show_carbon=""
source=""
electricity_maps_token = ""

while [[ $# -gt 0 ]]; do
opt="$1"
Expand Down Expand Up @@ -212,7 +213,12 @@ while [[ $# -gt 0 ]]; do
source="$2"
shift
;;
\?) echo "Invalid option -$1" >&2
-emt|--electricity_maps_token)
electricity_maps_token="$2"
shift
;;
*) echo "Invalid option -$1" >&2
exit 1
;;
esac
shift
Expand Down
4 changes: 4 additions & 0 deletions scripts/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ get_carbon_intensity() {
latitude=$1
longitude=$2

echo "TOKEN IS $electricity_maps_token"

if [ -z "${ELECTRICITY_MAPS_TOKEN+x}" ]; then
export ELECTRICITY_MAPS_TOKEN='no_token'
fi
Expand Down Expand Up @@ -235,6 +237,7 @@ if [ $# -eq 0 ]; then
exit 1
fi

electricity_maps_token = ""
option="$1"
case $option in
cpu_vars)
Expand All @@ -248,6 +251,7 @@ case $option in
;;
get_co2)
get_co2_val $2
electricity_maps_token="$3"
;;
*)
echo "Invalid option ($option). Please specify an option: cpu_vars, or add_var [key] [value]."
Expand Down

0 comments on commit 41b731b

Please sign in to comment.