-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (54 loc) · 1.71 KB
/
build-and-release-send-ci-cd-trace-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
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 }}