forked from graphql/graphql-js
-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (54 loc) · 1.6 KB
/
deploy-artifact-as-branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Deploy specified artifact as a branch
on:
workflow_call:
inputs:
environment:
description: Environment to publish under
required: true
type: string
artifact_name:
description: Artifact name
required: true
type: string
target_branch:
description: Target branch
required: true
type: string
commit_message:
description: Commit message
required: true
type: string
permissions: {}
jobs:
deploy-artifact-as-branch:
environment:
name: ${{ inputs.environment }}
url: ${{ github.server_url }}/${{ github.repository }}/tree/${{ inputs.target_branch }}
runs-on: ubuntu-latest
permissions:
contents: write # for actions/checkout and to push branch
steps:
- name: Checkout `${{ inputs.target_branch }}` branch
uses: actions/checkout@v4
with:
ref: ${{ inputs.target_branch }}
- name: Remove existing files first
run: git rm -r .
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact_name }}
- name: Publish target branch
run: |
git add -A
if git diff --staged --quiet; then
echo 'Nothing to publish'
else
git config user.name 'GitHub Action Script'
git config user.email 'please@open.issue'
git commit -a -m "$COMMIT_MESSAGE"
git push
echo 'Pushed'
fi
env:
TARGET_BRANCH: ${{ inputs.target_branch }}
COMMIT_MESSAGE: ${{ inputs.commit_message }}