Workflow file for this run
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: Deploy WP Project | |
on: | |
release: | |
types: [published] | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
env: | |
# Ensure that packages are not symlinked | |
COMPOSER_MIRROR_PATH_REPOS: 1 | |
jobs: | |
deploy: | |
name: Deploy WP Project | |
needs: [details] | |
runs-on: ubuntu-latest | |
if: ${{ fromJson(needs.details.outputs.result).shouldDeploy }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.ACCESS_TOKEN_IR }} | |
- name: Setup Environment | |
uses: ./actions/setup | |
with: | |
enable-wireit-cache: true | |
- name: Prepare bundle | |
run: | | |
pnpm wpdev bundle ${{ fromJson(needs.details.outputs.result).name }} | |
- name: Upload release assets | |
uses: AButler/[email protected] | |
with: | |
# e.g. dist/plugin-name-1.0.0.zip | |
files: "dist/${{ fromJson(needs.details.outputs.result).relativeDir }}-${{ fromJson(needs.details.outputs.result).version }}.zip" | |
repo-token: ${{ secrets.ACCESS_TOKEN_IR }} | |
- name: Install svn | |
run: sudo apt-get install subversion | |
- name: Deploy to WordPress.org | |
id: deploy | |
uses: 10up/action-wordpress-plugin-deploy@stable | |
env: | |
SLUG: ${{ fromJson(needs.details.outputs.result).name }} | |
VERSION: ${{ fromJson(needs.details.outputs.result).version }} | |
BUILD_DIR: "dist/${{ fromJson(needs.details.outputs.result).relativeDir }}" | |
ASSETS_DIR: "${{ fromJson(needs.details.outputs.result).relativeDir }}/.wordpress-org" | |
SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | |
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | |
- name: Copy README.md to dist | |
run: | | |
cp ${{ fromJson(needs.details.outputs.result).relativeDir }}/README.md dist/${{ fromJson(needs.details.outputs.result).relativeDir }}/README.md | |
- name: Deploy to repo | |
uses: manzoorwanijk/action-deploy-to-repo@v3 | |
with: | |
src_dir: dist/${{ fromJson(needs.details.outputs.result).relativeDir }} | |
target_repo: ${{ github.repository_owner }}/${{ fromJson(needs.details.outputs.result).name }} | |
target_dir: "." | |
target_branch: main | |
access_token: ${{ secrets.ACCESS_TOKEN_IR }} | |
# Remove everything from the target repo before deploying | |
cleanup_command: git rm -rf . && git clean -fxd | |
git_user_email: ${{ secrets.GIT_USER_EMAIL_IR }} | |
git_user_name: ${{ secrets.GIT_USER_NAME_IR }} | |
details: | |
name: Get details | |
runs-on: ubuntu-latest | |
outputs: | |
result: ${{ steps.details.outputs.result }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.ACCESS_TOKEN_IR }} | |
- name: Setup Environment | |
uses: ./actions/setup | |
with: | |
enable-wireit-cache: true | |
- name: List projects | |
id: projects | |
run: | | |
echo "result=$(pnpm wpdev project-info --all)" >> $GITHUB_OUTPUT | |
- name: Get details | |
uses: actions/github-script@v7 | |
id: details | |
with: | |
script: | | |
const tagRegex = /^(?<name>.+)@(?<version>[^@]+)$/; | |
const result = '${{ github.event.release.tag_name }}'.match(tagRegex); | |
if (!result?.groups?.name || !result?.groups?.version) { | |
console.warn('Invalid tag name: "${{ github.event.release.tag_name }}"'); | |
return { shouldDeploy: false }; | |
} | |
const { name, version } = result.groups; | |
const projects = ${{ steps.projects.outputs.result }}; | |
const project = projects.find(project => project.name === name); | |
const shouldDeploy = Boolean(project); | |
// User the version from the tag to ensure we're deploying the correct version | |
return { ...project, name, version, shouldDeploy }; | |
- name: Print details | |
run: | | |
echo "Details: ${{ steps.details.outputs.result }}" |