Repository navigation
Update libs from CodeOnTheGo #55
Workflow file for this run
This file contains hidden or 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: Update libs from CodeOnTheGo | |
| # TEMPORARY -- DO NOT MERGE TO main. | |
| # | |
| # On this branch only, this workflow is cut down to one job: build Layout Editor | |
| # and scp it to the GreenGeeks web host, the deploy that was removed in d09f05a | |
| # when addon delivery moved to Cloudflare R2. Dispatch it against this branch | |
| # (gh workflow run "Update libs from CodeOnTheGo" --ref <this branch>); the file | |
| # already exists on main, so GitHub registers the dispatch and runs the branch's | |
| # copy without main having to change. | |
| # | |
| # Dropped for the duration, so a one-shot upload has no side effects: the libs/ | |
| # commit and push (it would push to this branch), the release tag, and the | |
| # GitHub release carrying every addon's .cgp. Restore this file from main when | |
| # the upload is done. | |
| # | |
| # Needs: vars GREENGEEKS_SSH_HOST and GREENGEEKS_SSH_USER, secret | |
| # GREENGEEKS_SSH_PRIVATE_KEY. | |
| on: | |
| workflow_dispatch: | |
| env: | |
| ADDON: Layout-Editor | |
| PLUGINS_REMOTE_PATH: public_html/flags/plugins | |
| permissions: | |
| contents: read | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| steps: | |
| - name: Checkout plugin-examples | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| cache-disabled: true | |
| add-job-summary: 'never' | |
| # Check the credentials before building, so a missing variable fails in | |
| # seconds rather than after the Gradle build. | |
| - name: Verify the deploy configuration | |
| env: | |
| GREENGEEKS_HOST: ${{ vars.GREENGEEKS_SSH_HOST }} | |
| GREENGEEKS_USER: ${{ vars.GREENGEEKS_SSH_USER }} | |
| GREENGEEKS_KEY: ${{ secrets.GREENGEEKS_SSH_PRIVATE_KEY }} | |
| run: | | |
| set -euo pipefail | |
| for v in GREENGEEKS_HOST GREENGEEKS_USER GREENGEEKS_KEY; do | |
| if [ -z "${!v}" ]; then | |
| echo "::error::$v is empty. Check the repository secrets and variables." | |
| exit 1 | |
| fi | |
| done | |
| # Deliberately not scripts/update-libs.sh. That overwrites libs/*.jar with a | |
| # fresh build from CodeOnTheGo stage, and stage's plugin-builder is compiled | |
| # against a newer AGP than the 8.11.0 every addon pins, so configuration | |
| # fails on ApplicationExtension.getDefaultConfig(). The libs committed to | |
| # this branch are the ones this .cgp was built and device-verified against. | |
| - name: Build the addon against the committed libs | |
| run: cd "plugins/$ADDON" && ./gradlew --console=plain assemblePlugin | |
| - name: Stage the .cgp | |
| run: | | |
| set -euo pipefail | |
| mkdir -p deploy-staging | |
| found=0 | |
| for f in "plugins/$ADDON"/build/plugin/*.cgp; do | |
| case "$f" in | |
| *-debug.cgp) continue ;; | |
| esac | |
| cp "$f" deploy-staging/ | |
| found=$((found + 1)) | |
| done | |
| if [ "$found" -ne 1 ]; then | |
| echo "::error::Expected exactly one release .cgp for $ADDON, found $found." | |
| exit 1 | |
| fi | |
| ls -la deploy-staging/ | |
| - name: Set up SSH key | |
| env: | |
| GREENGEEKS_HOST: ${{ vars.GREENGEEKS_SSH_HOST }} | |
| GREENGEEKS_KEY: ${{ secrets.GREENGEEKS_SSH_PRIVATE_KEY }} | |
| GREENGEEKS_USER: ${{ vars.GREENGEEKS_SSH_USER }} | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "$GREENGEEKS_KEY" > ~/.ssh/id_rsa | |
| sed -i '$ { /^$/ d; }' ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| if ! grep -q "BEGIN.*PRIVATE KEY" ~/.ssh/id_rsa; then | |
| echo "::error::SSH key does not appear to be in correct format" | |
| exit 1 | |
| fi | |
| cat > ~/.ssh/config <<EOF | |
| Host * | |
| IdentitiesOnly yes | |
| PreferredAuthentications publickey | |
| StrictHostKeyChecking no | |
| UserKnownHostsFile ~/.ssh/known_hosts | |
| PubkeyAuthentication yes | |
| PasswordAuthentication no | |
| Host $GREENGEEKS_HOST | |
| User $GREENGEEKS_USER | |
| IdentityFile ~/.ssh/id_rsa | |
| ControlMaster auto | |
| ControlPath ~/.ssh/cm-%r@%h:%p | |
| ControlPersist 10m | |
| ConnectTimeout 60 | |
| ServerAliveInterval 60 | |
| ServerAliveCountMax 10 | |
| EOF | |
| chmod 600 ~/.ssh/config | |
| unset SSH_AUTH_SOCK | |
| unset SSH_AGENT_PID | |
| ssh-keyscan -H "$GREENGEEKS_HOST" >> ~/.ssh/known_hosts 2>/dev/null | |
| - name: Upload the .cgp via scp | |
| env: | |
| REMOTE: ${{ vars.GREENGEEKS_SSH_USER }}@${{ vars.GREENGEEKS_SSH_HOST }} | |
| run: | | |
| set -euo pipefail | |
| for f in deploy-staging/*.cgp; do | |
| echo "Uploading $f -> $REMOTE:$PLUGINS_REMOTE_PATH/$(basename "$f")" | |
| scp "$f" "$REMOTE:$PLUGINS_REMOTE_PATH/" | |
| done | |
| - name: Verify the remote checksum | |
| env: | |
| REMOTE: ${{ vars.GREENGEEKS_SSH_USER }}@${{ vars.GREENGEEKS_SSH_HOST }} | |
| run: | | |
| set -euo pipefail | |
| names=$(cd deploy-staging && ls *.cgp | tr '\n' ' ') | |
| remote_sums=$(ssh "$REMOTE" "cd $PLUGINS_REMOTE_PATH && md5sum $names") | |
| echo "$remote_sums" | |
| (cd deploy-staging && md5sum $names) | while read -r sum name; do | |
| if ! echo "$remote_sums" | grep -q "^$sum $name$"; then | |
| echo "::error::Checksum mismatch for $name after upload." | |
| exit 1 | |
| fi | |
| echo "OK $name" | |
| done |