feat: refactor release pipeline #9
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: generate page site | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
name: Publish to Cloudflare Pages | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- run: npm ci | |
- run: npm run docs:build | |
- name: Compare Versions | |
run: | | |
TAG_VERSION=$(echo ${{env.TAG}} | tr -dc '0-9') | |
PACKAGE_VERSION=$(echo ${{env.PACKAGE}} | tr -dc '0-9') | |
if (( $((10#$PACKAGE_VERSION + 1)) > $((10#$TAG_VERSION + 1)) )); then | |
echo "new version ready to release" | |
echo "RELEASE=true" >> "$GITHUB_ENV" | |
else | |
echo "no new version to release" | |
echo "RELEASE=false" >> "$GITHUB_ENV" | |
fi | |
- uses: neverendingqs/gh-action-tag-on-npm-version@master | |
if: env.RELEASE == 'true' && github.ref == 'refs/heads/master' | |
- name: Build Release | |
uses: "marvinpinto/action-automatic-releases@latest" | |
if: env.RELEASE == 'true' && github.ref == 'refs/heads/master' | |
with: | |
prerelease: false | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
files: | | |
dist/**/* | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
if: env.RELEASE == 'true' && github.ref == 'refs/heads/master' | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: dockit-site | |
directory: dist | |
# Optional: Enable this if you want to have GitHub Deployments triggered | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
branch: main | |
environment: production |