-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (105 loc) · 4.36 KB
/
build-emoji-release.yaml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: build emoji release
on:
workflow_dispatch:
inputs:
dry-run:
type: boolean
description: Run the workflow without creating a pull request
required: false
default: false
versions:
type: string
description: The versions to build the emoji release for
required: true
default: ""
pull_request:
types:
- closed
branches:
# this will limit the github actions a bit.
- main
paths:
- emojis.lock
- data/**
permissions: {}
jobs:
build-emoji-release:
# only run if the pr was merged and originated from the 'new-emoji-release' branch or manually triggered
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'new-emoji-release') }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 10
persist-credentials: false
- name: setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- name: setup node
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: lts/*
- name: install dependencies
run: pnpm install
- name: get new releases
id: new-releases
if: github.event_name != 'workflow_dispatch'
run: |
PREV_COMMIT=$(git rev-parse HEAD^)
git show $PREV_COMMIT:emojis.lock > previous_emojis.lock
DIFF=$(jq -n \
--slurpfile before previous_emojis.lock \
--slurpfile after emojis.lock \
'($before[0].versions | map(.emoji_version) | map(tostring)) as $oldVersions |
($after[0].versions | map(.emoji_version) | map(tostring)) as $newVersions |
$newVersions | map(select(. as $v | $oldVersions | index($v) | not))[] |
select(.)' | tr '\n' ' ')
echo "DIFF_VERSIONS=$DIFF" >> $GITHUB_OUTPUT
- name: determine emoji versions
id: emoji-versions
env:
VERSIONS: ${{ github.event.inputs.versions }}
AUTO_VERSIONS: ${{ steps.new-releases.outputs.DIFF_VERSIONS }}
run: |
SEPARATED_VERSIONS=$(echo $VERSIONS | tr ',' ' ')
# use manual versions if provided, otherwise fallback to auto-detected versions
FINAL_VERSIONS="${SEPARATED_VERSIONS:-$AUTO_VERSIONS}"
echo "using versions: $FINAL_VERSIONS"
echo "FINAL_VERSIONS=$FINAL_VERSIONS" >> $GITHUB_OUTPUT
- name: generate
env:
FINAL_VERSIONS: ${{ steps.emoji-versions.outputs.FINAL_VERSIONS }}
run: |
echo "version: $(pnpm dlx @mojis/cli@latest --version)"
echo "final versions: $FINAL_VERSIONS"
pnpm dlx @mojis/cli@latest generate $FINAL_VERSIONS
- name: detect changes for `emojis.lock`
id: has-lock-changes
run: |
# set has-lock-changes to true if emojis.lock has changes
if git diff --exit-code emojis.lock; then
echo "no changes detected in emojis.lock"
echo "has-lock-changes=false" >> $GITHUB_OUTPUT
else
echo "changes detected in emojis.lock"
echo "has-lock-changes=true" >> $GITHUB_OUTPUT
fi
- name: create pull request
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
if: ${{ github.event.inputs.dry-run != 'true' && steps.has-lock-changes.outputs.has-lock-changes == 'true' }}
with:
commit-message: "feat: update emojis"
title: "feat: update emojis"
body: |
I was recently triggered to update the emoji data, with a new release or multiple releases.
I don't know what they changed, but I'm sure it's awesome 🤖.
I will be waiting for your approval 👋.
This is an automated PR to update the emoji data.
branch: update-emojis
add-paths: data/*,emojis.lock
base: main
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
reviewers: luxass