Skip to content

Build and Release send-ci-cd-trace Action #2

Build and Release send-ci-cd-trace Action

Build and Release send-ci-cd-trace Action #2

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 "actions@github.com"
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 }}