Generate data files #2809
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate data files | |
on: | |
schedule: | |
- cron: '40 6,12,18 * * *' | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Generate | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: 'source' | |
- name: Checkout Symfony repo | |
run: git clone https://github.com/symfony/symfony symfony | |
- name: Download dependencies | |
run: | | |
cd source | |
composer install --no-interaction --optimize-autoloader | |
- name: Generate data files | |
run: | | |
WORKDIR=$(pwd) | |
for version in $(cd $WORKDIR/source && php bin/console app:supported-versions); do | |
cd $WORKDIR/symfony && git checkout $version | |
cd $WORKDIR/source && php bin/console app:trans-stats $WORKDIR/symfony > config/data/$version.json | |
done | |
- name: Commit & push the new files | |
id: commit_push | |
run: | | |
echo "::group::git status" | |
cd source | |
git status | |
echo "::endgroup::" | |
git add -N . | |
if [[ $(git diff --numstat | wc -l) -eq 0 ]]; then | |
echo "No changes found. Exiting." | |
echo "::set-output name=publish::false" | |
exit 0; | |
fi | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Bot" | |
echo "::group::git push" | |
git add . | |
git commit -m "Update data files" | |
git push | |
echo "::endgroup::" | |
echo "::set-output name=publish::true" | |
- name: Build website | |
env: | |
CUSTOM_GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }} | |
run: | | |
cd source | |
bin/console app:build-website | |
- name: Deploy website | |
if: ${{ github.event_name == 'push' || steps.commit_push.outputs.publish == 'true' }} | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: "eu-central-1" | |
run: aws s3 sync ./source/build s3://symfony-translations.nyholm.tech --cache-control max-age=7200 |