-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(actions): use otel to push gh data (#1044)
* feat: add send-ci-cd-trace action * use traces in annotation workflow * ignore last step * fix check last step * fix path * fix again * fix again * fix node version * fix action * fxi action * fix action * move role to gh auth * actually send spans * add debug and force flush spans * use the correct pkg * fix action * add common attributes * require gh token * fix relase action * commit dist only from release workflow * fix release aciton * update workflow
- Loading branch information
Showing
8 changed files
with
2,886 additions
and
1 deletion.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
.github/workflows/build-and-release-send-ci-cd-trace-action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Build and Release send-ci-cd-trace Action | ||
|
||
env: | ||
WORKDIR: actions/send-ci-cd-trace | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
git_tag: | ||
description: 'Tag name for the release' | ||
required: true | ||
default: '0.0.1' | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
environment: actions-prod | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: npm | ||
cache-dependency-path: '${{ env.WORKDIR }}/package-lock.json' | ||
|
||
- name: Install Dependencies | ||
run: npm ci --ignore-scripts | ||
working-directory: ${{ env.WORKDIR }} | ||
|
||
- name: Build the Action | ||
run: npm run build | ||
working-directory: ${{ env.WORKDIR }} | ||
|
||
- name: Commit built code | ||
working-directory: ${{ env.WORKDIR }} | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "[email protected]" | ||
git add -f dist/ # Force add the dist folder, bypassing .gitignore | ||
git commit -m "Add built files for release [skip ci]" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create and push tag | ||
id: create_tag | ||
run: | | ||
TAG_NAME="v$(date +'%Y%m%d%H%M%S')" # Create a unique tag with a timestamp | ||
git tag $TAG_NAME | ||
git push origin $TAG_NAME | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create and push tag | ||
if: ${{ success() }} | ||
run: | | ||
TAG_NAME="${{ inputs.git_tag }}" | ||
git tag $TAG_NAME | ||
git push origin $TAG_NAME | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ on: | |
version: | ||
description: 'Application version' | ||
required: true | ||
owner: | ||
team: | ||
description: 'Owner or team name' | ||
required: true | ||
default: 'platform' | ||
|
@@ -56,3 +56,10 @@ jobs: | |
\"time\": ${timestamp} | ||
}" | ||
- name: Send Trace to Azure Monitor | ||
uses: altinn/altinn-platform/actions/[email protected] | ||
with: | ||
connection_string: ${{ secrets.APP_INSIGHTS_CONNECTION_STRING }} | ||
app: "${{ github.event.inputs.app }}" | ||
team: "${{ github.event.inputs.team }}" | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Node Modules | ||
node_modules/ | ||
|
||
# Build Output | ||
coverage/ | ||
dist/ | ||
|
||
# TypeScript Cache and Output | ||
*.tsbuildinfo | ||
|
||
# Logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
|
||
# OS Specific Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Environment Variables | ||
.env | ||
.env.local | ||
.env.*.local | ||
|
||
# IDE/Editor Specific Files | ||
.idea/ | ||
.vscode/ | ||
*.swp | ||
*.swo | ||
*.swn | ||
|
||
# Tests | ||
__tests__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: 'Send CI/CD Trace to Azure Monitor' | ||
description: 'Collects jobs and steps metrics from GitHub Actions workflow and send them to Azure Application Insights' | ||
author: 'Digdir' | ||
inputs: | ||
app: | ||
description: 'Name of the App' | ||
required: true | ||
team: | ||
description: 'Name of the team that owns the App' | ||
required: true | ||
connection_string: | ||
description: 'Azure Application Insights Connection String' | ||
required: true | ||
repo_token: | ||
description: 'GitHub Token for accessing workflow data in private repositories' | ||
required: true | ||
runs: | ||
using: 'node20' | ||
main: 'dist/index.js' |
Oops, something went wrong.