-
Notifications
You must be signed in to change notification settings - Fork 49
101 lines (85 loc) · 2.74 KB
/
generate-preview.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Generate asciinema preview gif
on:
push:
tags:
- 'v*'
jobs:
generate:
runs-on: ubuntu-latest
env:
DEMO_MAGIC_INSTALL: /tmp/demo-magic
TERM: xterm
steps:
# Checks-out the project under $GITHUB_WORKSPACE/git-gud
- uses: actions/checkout@v2
with:
fetch-depth: 0
path: git-gud
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- uses: actions/setup-node@v1
with:
node-version: '14'
- name: Set up packager-managed dependencies for gif build
# demo-magic.sh requires [pv]
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install $GITHUB_WORKSPACE/git-gud
pip install asciinema
sudo apt-get install pv
- name: Download demo-magic.sh from repository
run: git clone --depth 1 https://github.com/paxtonhare/demo-magic.git $DEMO_MAGIC_INSTALL
- name: Test functionality of preview commands
run: |
chmod +x $GITHUB_WORKSPACE/git-gud/previewgif.sh
$GITHUB_WORKSPACE/git-gud/previewgif.sh $GITHUB_WORKSPACE/git-gud
- name: Record to asciinema cast file (JSON)
run: |
python3 -m asciinema rec -c "$GITHUB_WORKSPACE/git-gud/previewgif.sh $GITHUB_WORKSPACE/git-gud" -e SHELL,TERM,DEMO_MAGIC_INSTALL asciicast.json
cp ./asciicast.json /tmp/build
- name: Upload asciicast.json
uses: actions/upload-artifact@v2
with:
name: asciicast.json
path: /tmp/build/asciicast.json
- name: Use dgzlopes/[email protected]
uses: dgzlopes/[email protected]
with:
input: asciicast.json
output: preview.gif
- name: Move preview.gif to build
run: |
mkdir /tmp/build
cp ./preview.gif /tmp/build
- name: Upload preview.gif
uses: actions/upload-artifact@v2
with:
name: preview.gif
path: /tmp/build/preview.gif
create-pr:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
needs: generate
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: preview.gif
- name: Set tag
id: vars
run: |
echo ::set-output name=tag::$(git describe --tags)
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
base: ascii-tagbranch
commit-message: Automated update of preview.gif
title: Updated preview.gif by create-pull-request@v3 action
branch: create-pull-request/previewgif-${{ steps.vars.outputs.tag }}