Skip to content

Commit

Permalink
New workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
p3lim committed Dec 20, 2024
1 parent 83dae5b commit 0bf3f9b
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 5 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
tags:
- '**'
workflow_dispatch: # so we can trigger it from another workflow

permissions:
contents: write # required to create a release

jobs:
release:
Expand All @@ -17,8 +21,20 @@ jobs:

- name: Package and release
uses: BigWigsMods/packager@v2
env:
CF_API_KEY: ${{ secrets.CF_API_KEY }}
WOWI_API_TOKEN: ${{ secrets.WOWI_API_TOKEN }}
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }}
WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }}
if: github.ref_type == 'tag' # ensure no rogue triggers
env:
CF_API_KEY: ${{ secrets.CF_API_KEY }}
WOWI_API_TOKEN: ${{ secrets.WOWI_API_TOKEN }}
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }}
WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }}

- name: Notify on failures
# when triggered by another workflow we won't get notifications from failures, this is a workaround
if: ${{ failure() }}
uses: appleboy/[email protected]
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
message: |
Workflow "${{ github.workflow }}" failed during job "${{ github.job }}"
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>
49 changes: 49 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Tag

on:
push:
branches:
- master
paths:
- CHANGELOG.md

permissions:
contents: write # needed to run `git push`
actions: write # needed to trigger other workloads

jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4

- name: Get latest version from changelog header
run: |
echo "tag=$(grep -oPm 1 '(?<=### Changes in )(.*)(?=:)' CHANGELOG.md)" >> "$GITHUB_OUTPUT"
id: changelog

- name: Bail if tag exists
run: |
! git show-ref -q --tags "${{ steps.changelog.outputs.tag }}" || {
echo "Tag ${{ steps.changelog.outputs.tag }} already exists"
exit 1
}
- name: Setup Git
run: |
git config user.name 'github-actions[bot]'
git config user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
- name: Tag and push
run: |
git tag -a -m "Tag ${{ steps.changelog.outputs.tag }}" ${{ steps.changelog.outputs.tag }}
git push origin ${{ steps.changelog.outputs.tag }}
- name: Trigger release workflow
# workflows won't trigger when other workflows do git actions, so we need to do this
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
run: |
gh workflow run release.yml --ref ${{ steps.changelog.outputs.tag }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/translate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create pull request from translation form

on:
issues:
types: [labeled]

env:
GITHUB_EVENT_ISSUE: ${{ github.event.issue.number }}

jobs:
extract:
if: ${{ github.event.label.name == 'translation' }}
runs-on: ubuntu-latest

steps:
- name: Clone project
uses: actions/checkout@v4

- name: Extract translations
uses: p3lim/lua-translations@master
with:
action: extract
id: extract

- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
title: Update ${{ steps.extract.outputs.lang }} translation
body:
commit-message: |
Update ${{ steps.extract.outputs.lang }} translation
Fixes #${{ github.event.issue.number }}
branch: update-translation-${{ github.event.issue.number }}
delete-branch: true
29 changes: 29 additions & 0 deletions .github/workflows/update-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Update translation issue template

on:
push:
branches:
- master
tags-ignore:
- '**'

jobs:
template:
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4

- name: Update issue template
uses: p3lim/lua-translations@master
with:
action: template

- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
title: Update translation issue template
body:
commit-message: Update translation issue template
branch: translation-issue-template
delete-branch: true

0 comments on commit 0bf3f9b

Please sign in to comment.