name: BuildAndTest
on:
push:
branches:
– ‘main’
– ‘!badges’
jobs:
build:
name: Autograding
runs-on: ubuntu-latest
steps:
– uses: actions/checkout@v2
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
– name: Build
run: |
cmake .
make
# add id to step so outputs can be referenced
– uses: education/autograding@v1
id: autograder
continue-on-error: true
# make dir for badges
– name: badges branch and make dir
run: |
git checkout badges || git checkout -b badges
mkdir -p .github/badges
# make points badge
– name: points badge
uses: emibcn/badge-action@v1
with:
LABEL: ‘Points’
STATUS: ${{ steps.autograder.outputs.Points }}
COLOR: cyan
path: ‘.github/badges/points.svg’
# commit and push badge if score has changed
– name: Commit badge
run: |
git config –local user.email ” ”
git config –local user.name “GitHub Action”
git add ‘.github/badges/points.svg’
git commit -m “Add/Update badge”
continue-on-error: true
– name: Push badge commit
uses: ad-m/github-push-action@master
if: ${{ success() }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: badges