v1.0.8 #13
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 Package to npmjs | |
on: | |
release: | |
types: [published] | |
jobs: | |
release-npmjs: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
run: npm i | |
- name: Build project | |
run: npm run build | |
- name: Publish package | |
run: npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
deploy-wprocket: | |
runs-on: ubuntu-latest | |
needs: release-npmjs | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Checkout WP Rocket repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_WORKFLOW_WPROCKET_ACCESS }} | |
repository: wp-media/wp-rocket | |
ref: develop | |
path: wp-rocket | |
- name: Checkout rocket-scripts | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_WORKFLOW_SELF_CHECKOUT }} | |
path: rocket-scripts | |
- name: Install dependencies | |
run: npm ci | |
working-directory: rocket-scripts | |
- name: Build project | |
run: npm run build | |
working-directory: rocket-scripts | |
- name: Get rocket-scripts version | |
id: get_version | |
run: | | |
VERSION=$(jq -r '.version' rocket-scripts/package.json) | |
echo "ROCKET_SCRIPTS_VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Checkout WP Rocket develop branch | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_WORKFLOW_WPROCKET_ACCESS }} | |
repository: wp-media/wp-rocket | |
ref: develop | |
- name: Update rocket-scripts files inside WP Rocket | |
run: | | |
cp rocket-scripts/dist/wpr-beacon.js wp-rocket/assets/js/wpr-beacon.js | |
cp rocket-scripts/dist/wpr-beacon.min.js wp-rocket/assets/js/wpr-beacon.min.js | |
cp rocket-scripts/dist/wpr-beacon.min.js.map wp-rocket/assets/js/wpr-beacon.min.js.map | |
- name: Move into wp-rocket folder | |
run: cd wp-rocket | |
- name: Update WP Rocket package.json | |
run: | | |
jq --arg version "$ROCKET_SCRIPTS_VERSION" \ | |
'.devDependencies["wp-rocket-scripts"] = $version' \ | |
package.json > package.json.tmp | |
mv package.json.tmp package.json | |
- name: Commit rocket-script update | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: update rocket-script | |
commit_user_name: WP Media GitHub Actions Bot | |
- name: create pull request | |
run: | | |
prs=$(gh pr list \ | |
--repo "wp-media/wp-rocket" \ | |
--head 'rocket-scripts' \ | |
--base 'develop' \ | |
--json title \ | |
--jq 'length') | |
if ((prs > 0)); then | |
echo "skip=true" >> "$GITHUB_OUTPUT" | |
else | |
gh pr create -B develop -H 'rocket-scripts' --title 'Update rocket-script' --body 'Created by Github action' | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_WORKFLOW_WPROCKET_ACCESS }} |