|
| 1 | +name: Update screenshots periodically |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + # Run weekly, at 3:30pm on Monday |
| 7 | + # https://cron.help/#30_15_*_*_1 |
| 8 | + - cron: '30 15 * * 1' |
| 9 | + |
| 10 | +env: |
| 11 | + TESTBED_IMAGE: "ghcr.io/isso-comments/isso-js-testbed:latest" |
| 12 | + |
| 13 | +jobs: |
| 14 | + update-screenshots: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + pull-requests: write |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v3 |
| 22 | + |
| 23 | + - name: Switch testbed image to ${{ env.TESTBED_IMAGE }} |
| 24 | + run: | |
| 25 | + sed -i "s|isso-js-testbed|${{ env.TESTBED_IMAGE }}|g" docker-compose.yml |
| 26 | + # Also remove the `build`: section so image is pulled, not built |
| 27 | + sed -i '/container_name: isso-client/{n;N;N;d}' docker-compose.yml |
| 28 | +
|
| 29 | + - name: Pull testbed from ${{ env.TESTBED_IMAGE }} |
| 30 | + run: docker pull ${{ env.TESTBED_IMAGE }} |
| 31 | + |
| 32 | + - name: Tag testbed image for local use |
| 33 | + run: docker tag ${{ env.TESTBED_IMAGE }} isso-js-testbed:latest |
| 34 | + |
| 35 | + - name: Build the stack |
| 36 | + run: docker compose build isso-server |
| 37 | + |
| 38 | + - name: Bring up containers |
| 39 | + run: docker compose up -d |
| 40 | + |
| 41 | + - name: Wait for isso-server container to be ready |
| 42 | + run: 'for i in $(seq 1 30); do [ "$(docker inspect -f {{.State.Health.Status}} isso-server)" = "healthy" ] && s=0 && break || s=$? && sleep 0.3; done; (exit $s)' |
| 43 | + |
| 44 | + - name: Update screenshots |
| 45 | + run: make docker-update-screenshots |
| 46 | + |
| 47 | + - name: Check for changes |
| 48 | + id: check-changes |
| 49 | + run: | |
| 50 | + if git diff --quiet isso/js/tests/screenshots/reference/; then |
| 51 | + echo "changes=false" >> $GITHUB_OUTPUT |
| 52 | + else |
| 53 | + echo "changes=true" >> $GITHUB_OUTPUT |
| 54 | + fi |
| 55 | +
|
| 56 | + - name: Create Pull Request |
| 57 | + if: steps.check-changes.outputs.changes == 'true' |
| 58 | + uses: peter-evans/create-pull-request@v5 |
| 59 | + with: |
| 60 | + commit-message: "Update reference screenshots" |
| 61 | + title: "Update reference screenshots" |
| 62 | + body: | |
| 63 | + This PR updates the reference screenshots generated by the automated workflow. |
| 64 | +
|
| 65 | + Please review the changes to ensure they are expected. |
| 66 | + branch: automated-screenshot-update |
| 67 | + delete-branch: true |
0 commit comments