Skip to content

Commit dcb3159

Browse files
author
1138-4EB
committed
extend workflow to publish releases automatically
1 parent 5cd62f0 commit dcb3159

File tree

3 files changed

+63
-19
lines changed

3 files changed

+63
-19
lines changed

.github/workflows/push.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: "push"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches-ignore:
7+
- 'releases/**'
8+
tags:
9+
- '*'
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- run: npm ci
16+
17+
- run: npm test
18+
19+
- name: Test action from sources
20+
uses: ./
21+
with:
22+
milliseconds: 1000
23+
24+
- run: npm run package
25+
- name: Package action.yml and README.md
26+
run: |
27+
sed 's#dist/index\.js#index\.js#g' action.yml > dist/action.yml
28+
cp USAGE.md dist/README.md
29+
30+
- name: Test packaged action
31+
uses: ./dist
32+
with:
33+
milliseconds: 1000
34+
35+
- if: startsWith(github.ref, 'refs/tags')
36+
name: Publish release
37+
run: |
38+
TAG=`echo "$GITHUB_REF" | sed 's#refs/tags/##g'`
39+
BRANCH="release/`echo "$TAG" | cut -d. -f1`"
40+
41+
git checkout --orphan "$BRANCH"
42+
git rm --cached -r .
43+
git add dist
44+
git clean -fdx
45+
git mv dist/* ./
46+
47+
git config --global user.email "publish@gha"
48+
git config --global user.name "GHA"
49+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
50+
51+
git commit -m "publish $TAG [$GITHUB_SHA]"
52+
git push origin +"$BRANCH"

.github/workflows/test.yml

-19
This file was deleted.

USAGE.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
This is a dummy JavaScript action that waits a given number of milliseconds:
2+
3+
```yaml
4+
uses: actions/javascript-action@v1
5+
with:
6+
milliseconds: 1000
7+
```
8+
9+
The purpose of this repository is to provide a template to bootstrap the creation of a JavaScript action :rocket:.
10+
11+
The template includes tests, linting, a validation workflow, publishing, and versioning guidance. See [default](https://github.com/actions/typescript-action) branch.

0 commit comments

Comments
 (0)