Skip to content

Commit cf634a2

Browse files
Add GitHub Actions workflows for build, pull request creation, and release drafting
1 parent d2518dc commit cf634a2

File tree

3 files changed

+101
-2
lines changed

3 files changed

+101
-2
lines changed

.github/workflows/build.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build application
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Tag version'
8+
required: true
9+
workflow_call:
10+
inputs:
11+
tag:
12+
type: string
13+
required: true
14+
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
19+
env:
20+
TAG_NAME: ${{ inputs.tag || github.event.inputs.tag }}
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
26+
name: Build
27+
28+
steps:
29+
- name: Detect version
30+
run: echo "New versions is $TAG_NAME"
31+
32+
- name: Checkout the code
33+
uses: actions/checkout@v6
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v6
37+
with:
38+
node-version: 20
39+
check-latest: true
40+
41+
- run: npm ci
42+
- run: npm run build
43+
44+
- name: Upload artifact
45+
uses: actions/upload-artifact@v6
46+
with:
47+
name: updater
48+
path: dist/index.js
49+
retention-days: 1
50+
51+
pull_request:
52+
runs-on: ubuntu-latest
53+
54+
needs: build
55+
56+
name: Create a Pull Request
57+
58+
steps:
59+
- name: Checkout the code
60+
uses: actions/checkout@v6
61+
62+
- name: Make a title
63+
id: title
64+
run: |
65+
echo "title=🏗️ Build the application version ${TAG_NAME}" >> "$GITHUB_OUTPUT"
66+
67+
- name: Show title
68+
run: echo ${{ steps.title.outputs.title }}
69+
70+
- name: Remove old file
71+
run: rm -f dist/index.js
72+
73+
- uses: actions/download-artifact@v7
74+
with:
75+
name: updater
76+
path: builds
77+
78+
- name: Create a Pull Request
79+
uses: peter-evans/create-pull-request@v8
80+
with:
81+
branch: build/app
82+
branch-suffix: random
83+
delete-branch: true
84+
add-paths: ./dist/index.js
85+
title: ${{ steps.title.outputs.title }}
86+
commit-message: ${{ steps.title.outputs.title }}
87+
body: Application compiled successfully
88+
labels: build

.github/workflows/release-drafter.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ on:
44
push:
55
branches:
66
- main
7+
paths-ignore:
8+
- '**dist/index.js'
79
workflow_dispatch:
810

911
jobs:
10-
Update:
12+
draft:
13+
name: Drafter
1114
uses: TheDragonCode/.github/.github/workflows/release-drafter.yml@main
15+
16+
build:
17+
needs: draft
18+
19+
name: App
20+
uses: TheDragonCode/github-preview-updater/.github/workflows/build.yml@main
21+
with:
22+
tag: ${{ needs.draft.outputs.tag_name }}

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup Node.js
1313
uses: actions/setup-node@v6
1414
with:
15-
node-version: lts/*
15+
node-version: 20
1616
check-latest: true
1717

1818
- run: npm ci

0 commit comments

Comments
 (0)