-
Notifications
You must be signed in to change notification settings - Fork 5
refactor: add github actions #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
b1351c4
refactor: move to github actions
miguelpeixe 558b5a1
fix: let the script create the db
miguelpeixe 656cf67
fix: release workflow
miguelpeixe ed7a28c
fix: post-release workflow
miguelpeixe 991821b
fix: i18n workflow
miguelpeixe 41b03ee
fix: i18n exclude src dir
miguelpeixe 025ea16
fix(i18n): increase php nesting level
miguelpeixe 3a37606
fix: create xdebug dir
miguelpeixe 172cc5d
fix: remove custom config
miguelpeixe 9849321
fix: alternate custom config strategy
miguelpeixe 74d2c85
fix: label char limit
miguelpeixe 37a87cc
fix: release command
miguelpeixe bfa681b
fix: post release vars and release asset
miguelpeixe 704b6ee
fix: release command
miguelpeixe 42fa51a
chore: temporarily disable pr comments (prevent spam)
miguelpeixe 55eade1
fix: set repo env var
miguelpeixe 43c99ca
fix: disable release labels
miguelpeixe a52324c
fix: github repo env var
miguelpeixe 1b654fa
fix: move repo var to parent repo
miguelpeixe 15be7d5
fix: rebase before push
miguelpeixe 7f5f389
fix: install mysql client
miguelpeixe ab7fabc
fix: add php setup
miguelpeixe 8399c70
fix: add php setup
miguelpeixe 6039e80
fix: move secret env
miguelpeixe 9dd364f
fix: fetch all history
miguelpeixe 3377358
fix: update permissions
miguelpeixe 15442fd
fix: update permissions
miguelpeixe f69ff62
fix: add GITHUB_REPOSITORY environment variable
miguelpeixe 7ee3840
Update .github/workflows/reusable-i18n.yml
miguelpeixe 1a22095
Update .github/workflows/release.yml
miguelpeixe 1947852
fix: add GIT_COMMITTER_NAME and GITHUB_COMMITTER_EMAIL to workflow
miguelpeixe 790f10c
Merge branch 'refactor/deprecate-circle-ci' of https://github.com/Aut…
miguelpeixe 083bc1f
refactor: replace GITHUB_REPOSITORY secret with github.repository in …
miguelpeixe 2bde1b7
chore: set fetch-depth to 0 in reusable-post-release workflow for com…
miguelpeixe b2da515
fix: remove XDEBUG_MODE from test command in reusable-test-php workflow
miguelpeixe 722c02a
chore: remove GITHUB_TOKEN requirement from reusable-generate-docs wo…
miguelpeixe 46dae4a
chore: add write permissions for contents in reusable-generate-docs w…
miguelpeixe 055fd86
fix: restore conditional posting of GitHub PR comments for specific b…
miguelpeixe b9ca882
fix: remove CircleCI references from release-wporg.sh
rbcorrales 27edf10
refactor: reusable WP.org release workflow (#226)
rbcorrales adb73f9
chore: restore circleci config
miguelpeixe a61eef4
chore: restore scripts
miguelpeixe 6afc6e1
feat: add script path resolution for GitHub Actions
miguelpeixe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - trunk | ||
| - alpha | ||
| - 'hotfix/**' | ||
| - 'epic/**' | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Build and Release | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Verify Node version | ||
| run: node --version | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci --legacy-peer-deps | ||
|
|
||
| - name: Release | ||
| env: | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| run: npm run semantic-release | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Build Distributable | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| archive-name: | ||
| description: 'Name of the ZIP archive distributable' | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| build-distributable: | ||
| name: Build distributable files | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Verify Node version | ||
| run: node --version | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.3' | ||
| tools: composer | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci --legacy-peer-deps | ||
|
|
||
| - name: Install rsync | ||
| run: sudo apt-get update && sudo apt-get install -y rsync | ||
|
|
||
| - name: Install PHP packages | ||
| run: composer install --no-dev --no-scripts | ||
rbcorrales marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Build plugin files | ||
| run: npm run build && npm run release:archive | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ inputs.archive-name }} | ||
| path: release/${{ inputs.archive-name }}.zip | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Build | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Install node dependencies | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Verify Node version | ||
| run: node --version | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci --legacy-peer-deps |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: Check TypeScript | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| check-typescript: | ||
| name: Validate TypeScript | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Verify Node version | ||
| run: node --version | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci --legacy-peer-deps | ||
|
|
||
| - name: Validate TypeScript | ||
| run: npm run typescript:check |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Generate Docs | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| generate-docs: | ||
| name: Generate documentation | ||
| runs-on: ubuntu-latest | ||
miguelpeixe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install dependencies | ||
| run: sudo apt-get update && sudo apt-get install -y graphviz plantuml | ||
|
|
||
| - name: Download PHPDocumentor | ||
| run: | | ||
| curl -L -o ./phpdocumentor https://phpdoc.org/phpDocumentor.phar | ||
| chmod +x ./phpdocumentor | ||
|
|
||
| - name: Generate documentation | ||
| run: ./phpdocumentor run -d . -t ./docs | ||
|
|
||
| - name: Switch to docs branch, commit, and push | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GIT_COMMITTER_NAME: ${{ vars.GIT_COMMITTER_NAME || 'github-actions[bot]' }} | ||
| GIT_COMMITTER_EMAIL: ${{ vars.GIT_COMMITTER_EMAIL || 'github-actions[bot]@users.noreply.github.com' }} | ||
| run: | | ||
| git config user.name "$GIT_COMMITTER_NAME" | ||
| git config user.email "$GIT_COMMITTER_EMAIL" | ||
| git checkout -b docs | ||
| git add -f docs | ||
| git commit -m "Update the docs" | ||
| git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" docs --force | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| name: i18n | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| i18n: | ||
miguelpeixe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| name: Create translation files | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
miguelpeixe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Check if commit author is bot | ||
| id: check-bot | ||
| env: | ||
| GIT_COMMITTER_EMAIL: ${{ vars.GIT_COMMITTER_EMAIL || 'github-actions[bot]@users.noreply.github.com' }} | ||
| run: | | ||
| COMMIT_AUTHOR=$(git log -1 --pretty=format:'%ae') | ||
| if [ "$COMMIT_AUTHOR" = "$GIT_COMMITTER_EMAIL" ]; then | ||
| echo "Commit was made by bot ($(git rev-parse --short HEAD)), skipping translation update" | ||
| echo "skip=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "skip=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Install dependencies | ||
| if: steps.check-bot.outputs.skip != 'true' | ||
| run: npm ci --legacy-peer-deps | ||
|
|
||
| - name: Configure PHP for deep nesting | ||
| if: steps.check-bot.outputs.skip != 'true' | ||
| run: | | ||
| # Increase xdebug max_nesting_level to handle deeply nested JS files | ||
| echo "xdebug.max_nesting_level=512" | sudo tee -a $(php -i | grep "Scan this dir for additional .ini files" | cut -d' ' -f9)/99-custom.ini | ||
|
|
||
miguelpeixe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Install WP CLI | ||
| if: steps.check-bot.outputs.skip != 'true' | ||
| run: | | ||
| curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | ||
| chmod +x wp-cli.phar | ||
| sudo mv wp-cli.phar /usr/local/bin/wp | ||
|
|
||
| - name: Build plugin files | ||
| if: steps.check-bot.outputs.skip != 'true' | ||
| run: npm run build || true | ||
|
|
||
| - name: Create POT translation files | ||
| if: steps.check-bot.outputs.skip != 'true' | ||
| env: | ||
| REPO_NAME: ${{ github.event.repository.name }} | ||
| run: | | ||
| # Theme is excluded, more in https://github.com/Automattic/newspack-theme/pull/2458 | ||
| if [ "$REPO_NAME" = "newspack-theme" ]; then | ||
| cd ./newspack-theme | ||
| wp i18n make-pot . languages/${REPO_NAME}.pot --exclude='src' --domain=${REPO_NAME} | ||
| cd - | ||
| else | ||
| wp i18n make-pot . languages/${REPO_NAME}.pot --domain=${REPO_NAME} | ||
| fi | ||
|
|
||
| - name: Create JSON translation files | ||
| if: steps.check-bot.outputs.skip != 'true' | ||
| env: | ||
| REPO_NAME: ${{ github.event.repository.name }} | ||
| run: | | ||
| if [ "$REPO_NAME" = "newspack-theme" ]; then | ||
| cd ./newspack-theme | ||
| fi | ||
|
|
||
| sudo apt-get update && sudo apt-get install -y gettext | ||
|
|
||
| cd languages | ||
|
|
||
| # Create PO files from POT if they don't exist | ||
| if [ ! -f "${REPO_NAME}-en_US.po" ]; then | ||
| echo "Creating ${REPO_NAME}-en_US.po from POT file" | ||
| wp i18n update-po ${REPO_NAME}.pot . | ||
| else | ||
| echo "${REPO_NAME}-en_US.po file already exists, skipping creation" | ||
| fi | ||
|
|
||
| for po in *.po; do | ||
| if [ -f "$po" ]; then | ||
| echo "Processing file $po …" | ||
| # Update translations according to the new POT file | ||
| msgmerge $po $REPO_NAME.pot -o $po.out | ||
| mv $po.out $po | ||
| msgfmt $po -o $(basename $po .po).mo | ||
| # no-purge since we need the JS translations for the next run | ||
| wp i18n make-json --no-purge $po . | ||
| fi | ||
| done | ||
|
|
||
| - name: Commit translation files | ||
| if: steps.check-bot.outputs.skip != 'true' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| REPO_NAME: ${{ github.event.repository.name }} | ||
| GIT_COMMITTER_NAME: ${{ vars.GIT_COMMITTER_NAME || 'github-actions[bot]' }} | ||
| GIT_COMMITTER_EMAIL: ${{ vars.GIT_COMMITTER_EMAIL || 'github-actions[bot]@users.noreply.github.com' }} | ||
| run: | | ||
| if [ "$REPO_NAME" = "newspack-theme" ]; then | ||
| cd ./newspack-theme | ||
| fi | ||
| if [ -d "languages" ]; then | ||
| LINES_CHANGED=$(git diff --numstat languages/ | awk '{sum += $1 + $2} END {print sum}') | ||
| # If no existing files were changed, check for new files | ||
| if [ -z "$LINES_CHANGED" ] || [ "$LINES_CHANGED" -eq 0 ]; then | ||
| LINES_CHANGED=$(git ls-files --others --exclude-standard languages/ | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}') | ||
| fi | ||
| else | ||
| LINES_CHANGED=0 | ||
| fi | ||
| LINES_CHANGED=${LINES_CHANGED:-0} | ||
| echo "Lines changed in languages/: $LINES_CHANGED" | ||
| if [ "$LINES_CHANGED" -gt 3 ]; then | ||
| git config user.email "$GIT_COMMITTER_EMAIL" | ||
| git config user.name "$GIT_COMMITTER_NAME" | ||
| git remote set-url origin https://x-access-token:$GITHUB_TOKEN@github.com/${{ github.repository }}.git | ||
| git add languages/ | ||
| git commit -m "chore: update translation files [skip ci]" | ||
| git pull --rebase origin ${{ github.ref_name }} | ||
| git push origin ${{ github.ref_name }} | ||
rbcorrales marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Lint JS & SCSS | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| lint-js-scss: | ||
| name: Lint JS & SCSS files | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Verify Node version | ||
| run: node --version | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci --legacy-peer-deps | ||
|
|
||
| - name: Run Linter | ||
| # Temporarily skip linting SCSS due to stylelint config updates. Remove :js when ready to re-enable linting of SCSS. | ||
| run: npm run lint:js |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: Lint PHP | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| php-version: | ||
| description: 'PHP version to use' | ||
| required: false | ||
| type: string | ||
| default: '8.3' | ||
|
|
||
| jobs: | ||
| lint-php: | ||
| name: Lint PHP files | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ inputs.php-version }} | ||
| tools: composer | ||
|
|
||
| - name: Install Composer dependencies | ||
| run: composer install | ||
|
|
||
| - name: Lint PHP files | ||
| run: ./vendor/bin/phpcs |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.