Replace placeholder version with tag-dev-sha for latest trunk releases #63
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: Publish plugin to Automattic/create-content-model-releases latest on trunk merge | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- trunk | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get most recent tag | |
id: get_tag | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
with: | |
fallback: 1.0.0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm ci | |
- name: Update version to latest trunk commit | |
run: "find . -type f -exec sed -i 's/0.0.0-placeholder/${{ steps.get_tag.outputs.tag }}-dev-${{ github.sha }}/g' {} +" | |
- name: Build and create plugin zip | |
run: npm run plugin-zip | |
- name: Create output directory | |
run: mkdir -p output | |
- name: Move plugin zip to output/ | |
run: mv create-content-model.zip output/ | |
- name: Get user email | |
id: get_email | |
run: | | |
EMAIL=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/users/${{ github.actor }} \ | |
| jq -r '.email // empty') | |
if [ -z "$EMAIL" ]; then | |
EMAIL="${{ github.actor }}@users.noreply.github.com" | |
fi | |
echo "email=$EMAIL" >> $GITHUB_OUTPUT | |
- name: Push zip to another repository | |
uses: cpina/github-action-push-to-another-repository@main | |
env: | |
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} | |
with: | |
source-directory: "output" | |
destination-github-username: "automattic" | |
destination-repository-name: "create-content-model-releases" | |
user-name: ${{ github.actor }} | |
user-email: ${{ steps.get_email.outputs.email }} | |
target-branch: test |