This repository has been archived by the owner on Jun 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
action.yml
68 lines (59 loc) · 2.4 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: "Carbon Measurement"
description: "Read in an infrastructure as code template and then estimate the carbon emissions"
inputs:
IACType:
description: "Type of file for Infrastructure as Code"
required: true
default: "arm"
IACFile:
description: "IAC Filename"
required: true
default: "infra.json"
CloudProvider:
description: "Cloud provider for your infrastructure."
required: true
CARBON_RATE_PROVIDER:
description: 'Your resource for CO2 data. Must be either "electricitymap" or "watttime".'
required: true
outputs:
grams_carbon_equivalent_per_kwh:
description: "Grams of Carbon Equivalent per kWh for the selected location"
value: ${{ steps.action-output.outputs.grams_carbon_equivalent_per_kwh }}
grams_emitted_over_24h:
description: "Grams of Carbon Equivalents emitted over 24 hours"
value: ${{ steps.action-output.outputs.grams_emitted_over_24h }}
runs:
using: composite
steps:
- name: Set default value for IACTemplateFile - ARM/Pulumi/Terraform
if: inputs.IACType == 'arm' || inputs.IACType == 'pulumi' || inputs.IACType == 'terraform'
run: echo "IACTemplateFile=${{inputs.IACFile}}" >> $GITHUB_ENV
shell: bash
- name: Set default value for IACTemplateFile - Bicep
if: inputs.IACType == 'bicep'
run: echo "IACTemplateFile=${GITHUB_RUN_ID}_ARM.json" >> $GITHUB_ENV
shell: bash
- name: Build bicep file
if: inputs.IACType == 'bicep'
uses: azure/bicep-build-action@v1.0.0
with:
bicepFilePath: ${{ inputs.IACFile }}
outputFilePath: ${{ env.ARMTemplateFilename }}
- name: Set IACType env variable
run: echo "IACType=${{inputs.IACType}}" >> $GITHUB_ENV
shell: bash
- name: Set CloudProvider env variable
run: echo "CloudProvider=${{inputs.CloudProvider}}" >> $GITHUB_ENV
shell: bash
- name: Set CARBON_RATE_PROVIDER env variable
run: echo "CARBON_RATE_PROVIDER=${{inputs.CARBON_RATE_PROVIDER}}" >> $GITHUB_ENV
shell: bash
- name: Set GO111MODULE to on
run: go env -w GO111MODULE=on
shell: bash
- id: action-output
name: Cd into directory and run the program
run: |
cd ${{ github.action_path }}/src/carbon-measure-action
go run ${{ github.action_path }}/src/carbon-measure-action/carbon_measure.go ${{ github.action_path }}/src/carbon-measure-action/githubOutput.go
shell: bash