Split into jobs #26
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: Prepare for translation | |
on: | |
push: | |
branches: ['pre-release'] | |
workflow_dispatch: | |
inputs: | |
tmate_enabled: | |
type: boolean | |
description: 'Enable "tmate" for debugging' | |
required: false | |
default: false | |
jobs: | |
setup: | |
name: Setup and Check POT | |
runs-on: ubuntu-latest | |
container: | |
image: publishpress/dev-workspace-terminal:future-free | |
outputs: | |
pot_has_changes: ${{ steps.check-pot-diff.outputs.POT_HAS_CHANGES }} | |
plugin_version: ${{ steps.get-plugin-version.outputs.PLUGIN_VERSION }} | |
steps: | |
- uses: actions/checkout@master | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ inputs.tmate_enabled }} | |
timeout-minutes: 10 | |
- name: Setup composer | |
run: | | |
composer validate | |
composer install | |
composer info:versions | |
- name: Get plugin version | |
id: get-plugin-version | |
run: | | |
PLUGIN_VERSION=$(pversion) | |
echo "PLUGIN_VERSION=$PLUGIN_VERSION" >> $GITHUB_OUTPUT | |
- name: Check POT differences | |
id: check-pot-diff | |
run: | | |
OUTPUT=$(composer check:pot-diff-md) | |
echo "OUTPUT=$OUTPUT" >> $GITHUB_OUTPUT | |
[[ "$OUTPUT" =~ "No messages found" ]] && \ | |
echo "POT_HAS_CHANGES=false" >> $GITHUB_OUTPUT || \ | |
echo "POT_HAS_CHANGES=true" >> $GITHUB_OUTPUT | |
build: | |
needs: setup | |
if: needs.setup.outputs.pot_has_changes == 'true' | |
runs-on: ubuntu-latest | |
container: | |
image: publishpress/dev-workspace-terminal:future-free | |
outputs: | |
zipfile_name: ${{ steps.build-package.outputs.ZIPFILE_NAME }} | |
steps: | |
- uses: actions/checkout@master | |
- name: Build package | |
id: build-package | |
run: | | |
ZIPFILE_NAME=$(pzipfile) | |
echo "ZIPFILE_NAME=$ZIPFILE_NAME" >> $GITHUB_OUTPUT | |
composer build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build-package.outputs.ZIPFILE_NAME }} | |
path: dist/${{ steps.build-package.outputs.ZIPFILE_NAME }} | |
retention-days: 7 | |
create-issue: | |
needs: [setup, build] | |
if: needs.setup.outputs.pot_has_changes == 'true' | |
runs-on: ubuntu-latest | |
env: | |
ISSUE_ASSIGNEE: andergmartins | |
ISSUE_CC: "@andergmartins" | |
GH_TOKEN: ${{ github.token }} | |
PLUGIN_VERSION: ${{ needs.setup.outputs.plugin_version }} | |
steps: | |
- name: Create or update issue | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const searchQuery = `POT file has changes that need to be reviewed for version ${process.env.PLUGIN_VERSION} in:title is:open`; | |
const issues = await github.rest.search.issuesAndPullRequests({ | |
q: searchQuery, | |
per_page: 1 | |
}); | |
const body = `The POT file check detected changes between the main branch and the current branch. | |
\nPlease review and update the PO files. | |
\nDownload the testing package for this version: ${{ steps.upload-artifact.outputs.artifact-url }} | |
\nCC: ${process.env.ISSUE_CC} | |
\nOutput of \`check:pot-diff\`: ${process.env.OUTPUT}`; | |
if (issues.data.total_count === 0) { | |
await github.rest.issues.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: `POT file has changes that need to be reviewed for version ${process.env.PLUGIN_VERSION}`, | |
body, | |
labels: ['translation'], | |
assignees: [process.env.ISSUE_ASSIGNEE] | |
}); | |
} else { | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issues.data.items[0].number, | |
body: `Additional changes detected. ${body}` | |
}); | |
} |