-
Notifications
You must be signed in to change notification settings - Fork 26
56 lines (50 loc) · 1.65 KB
/
test.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
on: [push]
jobs:
test:
runs-on: ubuntu-latest
name: A job to test this action
steps:
- uses: actions/checkout@v1
- name: Generate a coverage value
id: coverage
run: |
# Generates a GitHub Workflow output named `lines`
echo "##[set-output name=lines;]${COVERAGE}"
# Create the directory where badges will be saved, if needed
mkdir -p "${BADGE_PATH%/*}"
echo "##[set-output name=path;]${BADGE_PATH}"
env:
COVERAGE: 53.5%
BADGE_PATH: .github/badges/test-badge.svg
# Use the output from the `coverage` step
- name: Generate the badge SVG image
uses: emibcn/badge-action@v1
id: badge
with:
label: 'Test coverage'
status: ${{ steps.coverage.outputs.lines }}
color: 'blue,555,daf'
path: ${{ steps.coverage.outputs.path }}
- name: Upload badge as artifact
uses: actions/upload-artifact@v2
with:
name: badge
path: ${{ steps.coverage.outputs.path }}
if-no-files-found: error
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Commit badge
env:
BADGE: ${{ steps.coverage.outputs.path }}
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add "${BADGE}"
git commit -m "Add/Update badge"
- name: Push badge commit
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.extract_branch.outputs.branch }}