Skip to content

build emoji release #37

build emoji release

build emoji release #37

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
with:
version: 10.5.x
- name: setup node
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: lts/*
- 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}"
FINAL_VERSIONS=$(echo "$FINAL_VERSIONS" | sed "s/[\"']//g")
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: create pull request
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
if: ${{ github.event.inputs.dry-run != '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