Skip to content

Commit

Permalink
Expose APPLICATION_INSIGHTS_KEY as environment for the following steps
Browse files Browse the repository at this point in the history
  • Loading branch information
waeltken committed Apr 21, 2021
1 parent 32db0c8 commit ba24653
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
27 changes: 9 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,20 @@ jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# checkout the repo
- name: "Checkout Github Action"
uses: actions/checkout@master
- uses: azure/login@v1
- uses: azure/login@v1 # Login to Azure
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Get Application Insights Key
id: insights # step id for later reference
# id: insights # step id for later reference
uses: waeltken/get-application-insights-key-action@v1
with:
resource-group-name: ${{ env.RESOURCE_GROUP_NAME }}
application-insights-name: ${{ env.APPLICATION_INSIGHTS_NAME }}

- name: Setup Node 10.x
uses: actions/setup-node@v1
with:
node-version: "10.x"
- name: "npm install, build, and test"
env:
# reference the application insights key:
APPLICATION_INSIGHTS_KEY: ${{ steps.insights.outputs.key }}
run: |
npm install
npm run build --if-present
npm run test --if-present
# The Action exposes the Application Insights Instrumentation Key as
# ${{ env.APPLICATION_INSIGHTS_KEY }}
# You can also access the value from the steps output like this:
# ${{ steps.insights.outputs.key }}
- name: "run more steps"
# APPLICATION_INSIGHTS_KEY environment variable visible here:
run: echo $APPLICATION_INSIGHTS_KEY
```
3 changes: 3 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ runs:
shell: bash
id: insights
run: echo "::set-output name=key::$(az resource show -g ${{ inputs.resource-group-name }} -n ${{ inputs.application-insights-name }} --resource-type 'microsoft.insights/components' --query 'properties.InstrumentationKey' -o tsv)"
- name: Expose key as environment variable
shell: bash
run: echo "APPLICATION_INSIGHTS_KEY=${{ steps.insights.outputs.key }}" >> $GITHUB_ENV

0 comments on commit ba24653

Please sign in to comment.