Skip to content

Commit

Permalink
feat(actions): use otel to push gh data (#1044)
Browse files Browse the repository at this point in the history
* 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
sduranc authored Oct 29, 2024
1 parent 6050d83 commit 7379b8e
Show file tree
Hide file tree
Showing 8 changed files with 2,886 additions and 1 deletion.
63 changes: 63 additions & 0 deletions .github/workflows/build-and-release-send-ci-cd-trace-action.yml
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 }}
9 changes: 8 additions & 1 deletion .github/workflows/grafana-annotation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
version:
description: 'Application version'
required: true
owner:
team:
description: 'Owner or team name'
required: true
default: 'platform'
Expand Down Expand Up @@ -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 }}
34 changes: 34 additions & 0 deletions actions/send-ci-cd-trace/.gitignore
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__/
19 changes: 19 additions & 0 deletions actions/send-ci-cd-trace/action.yml
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'
Loading

0 comments on commit 7379b8e

Please sign in to comment.