2022-04-15 10:01:46 +00:00
|
|
|
name: Deploy to staging
|
|
|
|
on:
|
2022-04-15 19:38:09 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
job_name:
|
|
|
|
description: "Job name that has completed"
|
|
|
|
required: true
|
|
|
|
type: string
|
2022-04-16 08:21:24 +00:00
|
|
|
rev:
|
|
|
|
description: "Revision of succeeded comit"
|
|
|
|
required: true
|
|
|
|
type: string
|
2022-04-15 10:01:46 +00:00
|
|
|
jobs:
|
|
|
|
deploy:
|
|
|
|
name: Deploy to staging
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-04-15 19:56:22 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-04-16 08:39:39 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.inputs.rev }}
|
2022-04-16 08:41:33 +00:00
|
|
|
token: ${{ secrets.PUBLISH_TOKEN }}
|
2022-04-16 08:21:24 +00:00
|
|
|
- run: |
|
2022-04-16 08:36:00 +00:00
|
|
|
JOB_NAME=$(echo $JOB_NAME | sed 's|:|/|g')
|
2022-04-16 16:02:34 +00:00
|
|
|
git fetch --all
|
|
|
|
git branch | grep $JOB_NAME || (git branch $JOB_NAME && git checkout $JOB_NAME && git push -u origin $JOB_NAME)
|
2022-04-16 08:42:48 +00:00
|
|
|
if [[ ! $(git merge-base --is-ancestor $REV $JOB_NAME) ]]; then
|
2022-04-16 16:02:34 +00:00
|
|
|
git checkout $JOB_NAME
|
|
|
|
git reset --hard $REV
|
|
|
|
git push --force
|
2022-04-16 08:31:23 +00:00
|
|
|
fi
|
2022-04-16 08:34:37 +00:00
|
|
|
env:
|
|
|
|
JOB_NAME: ${{ github.event.inputs.job_name }}
|
|
|
|
REV: ${{ github.event.inputs.rev }}
|