Skip to content

Commit daf6f8c

Browse files
committed
check
0 parents  commit daf6f8c

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

.github/workflows/test.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on: [push]
2+
3+
jobs:
4+
publish-directory:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- run: |
9+
mkdir build
10+
echo "<html><title> github actions publish ${{ github.run_id }} </title></html>" > build/index.html
11+
- uses: ./
12+
with:
13+
repo_name: ${{ github.repository }}
14+
branch: gh-pages
15+
directory: ${{ github.workspace }}/build
16+
commit_message: "publish directory to branch"

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Github actions to publish branch to github repository branch. It uses action's access_token to publish/write branch. required params need to be set
2+
3+
```yaml
4+
on: [push]
5+
6+
jobs:
7+
publish-directory:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: cedricbuild/gh-publish-branch@main
11+
with:
12+
github_repository: ${{ github.repository }}
13+
branch: gh-pages
14+
directory: build
15+
commit_message: "publish directory to branch"
16+
```

action.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Publish To Github"
2+
description: "Push/Update Branch from a directory. Built for compilaiton to creating actions, publishing Github Pages"
3+
inputs:
4+
repo_name:
5+
description: "Repository name with owner. For example, cedric05/dothttp"
6+
required: true
7+
default: ${{ github.repository }}
8+
branch:
9+
description: The branch to push
10+
required: true
11+
directory:
12+
description: "Directory to push"
13+
required: true
14+
commit_message:
15+
description: "commit message"
16+
required: true
17+
default: "publish directory to branch"
18+
committer_email:
19+
description: "commiter email id"
20+
default: "[email protected]"
21+
required: true
22+
committer_username:
23+
description: "commiter email id"
24+
default: "[email protected]"
25+
required: true
26+
runs:
27+
using: "composite"
28+
steps:
29+
- name: Checkout
30+
uses: rodrigorodriguescosta/checkout@main
31+
with:
32+
repository: ${{ inputs.repo_name }}
33+
path: /tmp/${{ inputs.repo_name }}
34+
ref: ${{ inputs.branch }}
35+
- run: |
36+
cd /tmp/${{ inputs.repo_name }}
37+
rm -rf *
38+
cp -r ${{ inputs.directory }}/* /tmp/${{ inputs.repo_name }}
39+
git config --global user.name "${{ inputs.committer_username }}"
40+
git config --global user.email "${{ inputs.committer_email }}"
41+
git add -A
42+
git commit -m "${{ inputs.commit_message }}"
43+
git push origin ${{ inputs.branch }}
44+
cd ..
45+
rm -rf /tmp/${{ inputs.repo_name }}
46+
shell: bash

0 commit comments

Comments
 (0)