forked from simplesamlphp/simplesamlphp
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (118 loc) · 4.43 KB
/
translations.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
name: Build translations
on: # yamllint disable-line rule:truthy
push:
branches: [master, simplesamlphp-*]
tags-ignore:
- '**'
paths:
- '**.po'
- '**.php'
- '**.twig'
workflow_dispatch:
jobs:
build:
name: Setup and Build PO-files
runs-on: ['ubuntu-latest']
outputs:
files_changed: ${{ steps.changes.outputs.files_changed }}
steps:
- name: Setup PHP, with composer and extensions
id: setup-php
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
# Should be the higest supported version, so we can use the newest tools
php-version: '8.3'
coverage: none
- uses: actions/checkout@v4
with:
# token: ${{ secrets.PAT_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
persist-credentials: false
fetch-depth: 0
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Generate new updated PO-files
run: php bin/translations translations:update:translatable --module main
- name: Diff the changes after building
shell: pwsh
# Give an id to the step, so we can reference it later
id: changes
run: |
git add --all
$Diff = git diff --cached --name-only
# Check if any of the translation files have changed (added, modified, deleted)
$SourceDiff = $Diff | Where-Object {
$_ -match '^*.po'
}
echo "Changed files"
echo $SourceDiff
$HasSourceDiff = $SourceDiff.Length -gt 0
echo "($($SourceDiff.Length) changes)"
echo "files_changed=$HasSourceDiff" >> $env:GITHUB_OUTPUT
- name: Zip artifact for deployment
if: steps.changes.outputs.files_changed == 'true' || steps.changes.outputs.packages_changed
run: zip build.zip -r .
- uses: actions/upload-artifact@v4
if: steps.changes.outputs.files_changed == 'true' || steps.changes.outputs.packages_changed
with:
name: build
path: build.zip
retention-days: 1
commit:
name: Commit changes to assets
needs: build
if: needs.build.outputs.files_changed == 'true'
runs-on: [ubuntu-latest]
steps:
- uses: actions/download-artifact@v4
with:
name: build
- name: unzip artifact for deployment
run: |
unzip build.zip
rm build.zip
- name: Add & Commit
uses: EndBug/add-and-commit@v9
with:
# The arguments for the `git add` command (see the paragraph below for more info)
# Default: '.'
add: "['**/*.po']"
fetch: false
push: false
# Determines the way the action fills missing author name and email. Three options are available:
# - github_actor -> UserName <[email protected]>
# - user_info -> Your Display Name <[email protected]>
# - github_actions -> github-actions <email associated with the github logo>
# Default: github_actor
default_author: github_actions
# The message for the commit.
# Default: 'Commit from GitHub Actions (name of the workflow)'
message: "[skip ci] Auto-rebuild translations"
# The way the action should handle pathspec errors from the add and remove commands.
# Three options are available:
# - ignore -> errors will be logged but the step won't fail
# - exitImmediately -> the action will stop right away, and the step will fail
# - exitAtEnd -> the action will go on, every pathspec error will be logged at the end, the step will fail.
# Default: ignore
pathspec_error_handling: exitImmediately
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref_name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cleanup:
name: Cleanup artifacts
needs: [build, commit]
runs-on: [ubuntu-latest]
if: |
always() &&
needs.commit.result == 'success' ||
(needs.build.result == 'success' && needs.commit.result == 'skipped')
steps:
- uses: geekyeggo/delete-artifact@v5
with:
name: |
build