pico/.github/workflows/deploy-branch.yml
Daniel Rudolf 60d0f5403c
CI: Use build script to publish new releases
Since Pico depends on PicoDeprecated, and PicoDeprecated depends on Pico, a chicken-egg-problem arises: When pushing a new tag for Pico, GitHub Actions will try to build this new release by downloading the matching version of PicoDeprecated from Packagist. Since we didn't release a new version of PicoDeprecated yet, this will fail. So we need to push PicoDeprecated's tag first. Doing so yields GitHub Actions trying to build PicoDeprecated's new release - by trying to download the matching version of Pico from Packagist, which doesn't exist yet.

Thus builds will always fail - unless you push both tags at the exact same time, and unless you send some prayers that GitHub Actions delays building until Packagist picks up the new releases. The simplest solution is not to use GitHub Actions to publish new releases, but letting the user to do it instead. With this changeset this is as simple as `make publish version=v3.0.0`. The 'deploy-release' GitHub workflow now just updates the website and is triggered by publishing the GitHub release, not the tag. This additionally allows the user to perform some manual tests before publication.

The build script now depends on GitHub CLI (`gh`), see https://cli.github.com/. You must setup authentication first (`gh auth login`).
2022-03-08 22:07:35 +01:00

98 lines
3.7 KiB
YAML

name: Git branch deployment
on:
push:
branches:
- 'master'
- 'pico-3.0'
env:
WEBSITE_REPO_SLUG: picocms/picocms.github.io
WEBSITE_REPO_BRANCH: master
CI_TOOLS_SETUP: https://raw.githubusercontent.com/picocms/ci-tools/master/setup.sh
jobs:
website:
name: Update website for branch updates
runs-on: ubuntu-latest
permissions:
contents: write
env:
PHP_VERSION: '7.4'
BUILD_DIR: ./build
WEBSITE_DIR: ./website
steps:
- name: Setup CI tools
run: |
. <(curl -fsS -L "$CI_TOOLS_SETUP")
echo "CI_TOOLS_PATH=$CI_TOOLS_PATH" | tee -a "$GITHUB_ENV"
- name: Checkout repository
uses: actions/checkout@v2
with:
path: ${{ env.BUILD_DIR }}
- name: Install Pico CMS
uses: ./build/.github/actions/install
with:
path: ${{ env.BUILD_DIR }}
php-version: ${{ env.PHP_VERSION }}
php-tools: phpdoc
- name: Read Pico milestone
working-directory: ${{ env.BUILD_DIR }}
run: |
PICO_VERSION_MILESTONE="$(php -r 'require("./lib/Pico.php"); preg_match("/^([0-9]+\.[0-9]+)\./", Pico::VERSION, $m); echo $m[1];')"
echo "PICO_VERSION_MILESTONE=$PICO_VERSION_MILESTONE" | tee -a "$GITHUB_ENV"
- name: Checkout website repository
uses: actions/checkout@v2
with:
repository: ${{ env.WEBSITE_REPO_SLUG }}
ref: ${{ env.WEBSITE_REPO_BRANCH }}
path: ${{ env.WEBSITE_DIR }}
#
# Update phpDoc class docs
#
- name: Update phpDoc class docs
run: |
"$CI_TOOLS_PATH/generate-phpdoc.sh" \
"$BUILD_DIR/.phpdoc.xml" \
"$WEBSITE_DIR/phpDoc/$GITHUB_REF_NAME" \
"$WEBSITE_DIR/phpDoc/$GITHUB_REF_NAME.cache" \
"Pico $PICO_VERSION_MILESTONE API Documentation ($GITHUB_REF_NAME branch)"
- name: Check for phpDoc class docs updates
run: |
PHPDOC_UPDATED="$([ -n "$(git -C "$WEBSITE_DIR" status --porcelain "phpDoc/$GITHUB_REF_NAME.cache")" ] && echo "yes" || echo "no")"
echo "PHPDOC_UPDATED=$PHPDOC_UPDATED" | tee -a "$GITHUB_ENV"
- name: Update phpDoc class docs list
if: ${{ env.PHPDOC_UPDATED == 'yes' }}
run: |
"$CI_TOOLS_PATH/update-phpdoc-list.sh" \
"$WEBSITE_DIR/_data/phpDoc.yml" \
"$GITHUB_REF_NAME" "branch" \
"<code>$GITHUB_REF_NAME</code> branch" "$(date +%s)"
- name: Commit phpDoc class docs updates
if: ${{ env.PHPDOC_UPDATED == 'yes' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
repository: ${{ env.WEBSITE_DIR }}
file_pattern: >-
phpDoc/${{ github.ref_name }}
phpDoc/${{ github.ref_name }}.cache
_data/phpDoc.yml
commit_user_name: Pico CMS Bot
commit_user_email: bot@picocms.org
commit_message: >-
Update phpDocumentor class docs
for ${{ github.ref_name }} branch
@ ${{ github.sha }}