nixos-config/.github/workflows/deploy.yml

34 lines
1 KiB
YAML
Raw Normal View History

2022-04-15 10:01:46 +00:00
name: Deploy to staging
on:
workflow_dispatch:
inputs:
job_name:
description: "Job name that has completed"
required: true
type: string
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
with:
ref: ${{ github.event.inputs.rev }}
token: ${{ secrets.PUBLISH_TOKEN }}
- 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 --remote | 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 }}