mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
95f8a2cd05
* Return early from dry run Determining whether to create a merge commit would elicit a nested conditional, which could be hard to parse for a human reader. This is avoided by returning early as soon as possible for a dry run. This also resolves the erroneous 'changes committed' message when no changes were actually committed because of the dry run. A message specific to dry-run is logged instead. * Add force parameter to action interface Existing behaviour is equivalent to force=true, so the default value is true. * Implement pull+rebase procedure * Declare force parameter in action * Detect both rejection syntaxes * Return both stdout and stderr from execute * Ignore non-zero exit status on push * Remove unnecessary error catch * Fetch and rebase in separate steps * Explicitly bind incoming branch I think the fetch will update the origin/gh-pages branch but not the gh-pages branch, despite requesting gh-pages. This means that when I later attempt to rebase the temp branch on top of the gh-pages branch, there will be nothing to do, because that's already where it is. * Implement attempt limit I don't expect this to ever require more than one attempt in production, but in theory it's possible that this procedure could loop forever. We would need to keep fetching and rebasing if changes keep being added to the remote. In practice, I believe this would only happen if there are lots of workflows simultaneously deploying to the same branch, all using this action. In this case only one would be able to secure a lock at a time, leading to the total number of attempts being equal to the number of simultaneous deployments, assuming each deployment makes each attempt at the exact same time. The limit may need to be increased or even be configurable, but 3 should cover most uses. * Update tests for execute output split * Document 'force' parameter * Create integration test for rebase procedure This test is composed of 3 jobs. The first two jobs run simultaneously, and as such both depend on the previous integration test only. The final job cleans up afterwards, and depends on both of the prior jobs. The two jobs are identical except that they both create a temporary file in a different location. This is to ensure that they conflict. Correctly resolving this conflict by rebasing one deployment over the other, resulting in a deployment containing both files, indicates a successful test.
329 lines
9.1 KiB
YAML
329 lines
9.1 KiB
YAML
name: integration-tests
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
branch:
|
|
description: 'Specifies the branch which the integration tests should run on.'
|
|
required: true
|
|
default: 'releases/v4'
|
|
schedule:
|
|
- cron: 30 15 * * 0-6
|
|
push:
|
|
tags-ignore:
|
|
- '*.*'
|
|
branches:
|
|
- releases/v4
|
|
|
|
jobs:
|
|
# Deploys cross repo with an access token.
|
|
integration-cross-repo-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
git-config-name: Montezuma
|
|
git-config-email: montezuma@jamesiv.es
|
|
repository-name: MontezumaIves/lab
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
branch: gh-pages
|
|
folder: integration
|
|
single-commit: true
|
|
clean: true
|
|
silent: true
|
|
|
|
# Deploys using checkout@v1 with an ACCESS_TOKEN.
|
|
integration-checkout-v1:
|
|
needs: integration-cross-repo-push
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
branch: gh-pages
|
|
folder: integration
|
|
target-folder: cat/montezuma
|
|
git-config-name: Montezuma
|
|
git-config-email: montezuma@jamesiv.es
|
|
silent: true
|
|
|
|
- name: Cleanup Generated Branch
|
|
uses: dawidd6/action-delete-branch@v3.1.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branches: gh-pages
|
|
|
|
# Deploys using checkout@v2 with a GITHUB_TOKEN.
|
|
integration-checkout-v2:
|
|
needs: integration-checkout-v1
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
branch: gh-pages
|
|
folder: integration
|
|
target-folder: cat/montezuma2
|
|
silent: true
|
|
|
|
- name: Cleanup Generated Branch
|
|
uses: dawidd6/action-delete-branch@v3.1.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branches: gh-pages
|
|
|
|
# Deploys using a container that requires you to install rsync.
|
|
integration-container:
|
|
needs: integration-checkout-v2
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ruby:2.6
|
|
env:
|
|
LANG: C.UTF-8
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Install rsync
|
|
run: |
|
|
apt-get update && apt-get install -y rsync
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
branch: gh-pages
|
|
folder: integration
|
|
target-folder: cat/montezuma2
|
|
silent: true
|
|
|
|
- name: Cleanup Generated Branch
|
|
uses: dawidd6/action-delete-branch@v3.1.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branches: gh-pages
|
|
|
|
# Deploys using an SSH key.
|
|
integration-ssh:
|
|
needs: integration-container
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
ssh-key: ${{ secrets.DEPLOY_KEY }}
|
|
branch: gh-pages
|
|
folder: integration
|
|
target-folder: cat/montezuma3
|
|
silent: true
|
|
|
|
- name: Cleanup Generated Branch
|
|
uses: dawidd6/action-delete-branch@v3.1.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branches: gh-pages
|
|
|
|
# Deploys using an SSH key.
|
|
integration-ssh-third-party-client:
|
|
needs: integration-ssh
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Install SSH Client
|
|
uses: webfactory/ssh-agent@v0.5.4
|
|
with:
|
|
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
ssh-key: true
|
|
branch: gh-pages
|
|
folder: integration
|
|
target-folder: cat/montezuma4
|
|
silent: true
|
|
|
|
- name: Cleanup Generated Branch
|
|
uses: dawidd6/action-delete-branch@v3.1.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branches: gh-pages
|
|
|
|
# Deploys using a custom env. (Includes subsequent commit)
|
|
integration-env:
|
|
needs: integration-ssh-third-party-client
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 'v14.18.1'
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
ssh-key: ${{ secrets.DEPLOY_KEY }}
|
|
branch: gh-pages
|
|
folder: integration
|
|
target-folder: cat/montezuma4
|
|
silent: true
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
ssh-key: ${{ secrets.DEPLOY_KEY }}
|
|
branch: gh-pages
|
|
folder: integration
|
|
target-folder: cat/subsequent
|
|
silent: true
|
|
|
|
- name: Cleanup Generated Branch
|
|
uses: dawidd6/action-delete-branch@v3.1.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branches: gh-pages
|
|
|
|
# Deploys using the CLEAN option.
|
|
integration-clean:
|
|
needs:
|
|
[
|
|
integration-checkout-v1,
|
|
integration-checkout-v2,
|
|
integration-container,
|
|
integration-ssh,
|
|
integration-ssh-third-party-client,
|
|
integration-env
|
|
]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
branch: gh-pages
|
|
folder: integration
|
|
clean: true
|
|
silent: true
|
|
|
|
# Deploys to a branch that doesn't exist with SINGLE_COMMIT. (Includes subsequent commit)
|
|
integration-branch-creation:
|
|
needs: integration-clean
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
branch: integration-test-delete-prod
|
|
folder: integration
|
|
single-commit: true
|
|
silent: true
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
branch: integration-test-delete-prod
|
|
folder: integration
|
|
single-commit: true
|
|
target-folder: jives
|
|
silent: true
|
|
|
|
- name: Cleanup Generated Branch
|
|
uses: dawidd6/action-delete-branch@v3.1.0
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branches: integration-test-delete-prod
|
|
|
|
# Creates two competing deployments, one of which should rebase over the other.
|
|
# First conflicting deployment
|
|
integration-rebase-conflicts-1:
|
|
needs: integration-branch-creation
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Create random file
|
|
runs: echo $RANDOM > integration/1
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
git-config-name: Montezuma
|
|
git-config-email: montezuma@jamesiv.es
|
|
repository-name: MontezumaIves/lab
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
branch: gh-pages-rebase-conflict
|
|
folder: integration
|
|
force: false
|
|
# Second conflicting deployment
|
|
integration-rebase-conflicts-2:
|
|
needs: integration-branch-creation
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Create random file
|
|
runs: echo $RANDOM > integration/2
|
|
|
|
- name: Build and Deploy
|
|
uses: JamesIves/github-pages-deploy-action@v4.2.5
|
|
with:
|
|
git-config-name: Montezuma
|
|
git-config-email: montezuma@jamesiv.es
|
|
repository-name: MontezumaIves/lab
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
branch: gh-pages-rebase-conflict
|
|
folder: integration
|
|
force: false
|
|
# Clean up conflicting deployments
|
|
integration-rebase-conflicts-cleanup:
|
|
needs: [integration-rebase-conflicts-1, integration-rebase-conflicts-2]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Cleanup Generated Branch
|
|
uses: dawidd6/action-delete-branch@v3.1.0
|
|
with:
|
|
github_token: ${{ secrets.ACCESS_TOKEN }}
|
|
owner: MontezumaIves
|
|
repository: lab
|
|
branches: gh-pages
|