From 71bdb5e27a51bc5c42606d05330646215577a8f5 Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Thu, 9 Jan 2020 20:03:02 -0500 Subject: [PATCH 1/4] Add a GitHub Action to post-process files --- .github/actions/publish/Dockerfile | 16 ++++++++++++++++ .github/actions/publish/entrypoint.sh | 15 +++++++++++++++ .github/workflows/main.yml | 17 +++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 .github/actions/publish/Dockerfile create mode 100644 .github/actions/publish/entrypoint.sh create mode 100644 .github/workflows/main.yml diff --git a/.github/actions/publish/Dockerfile b/.github/actions/publish/Dockerfile new file mode 100644 index 000000000..cd68f6014 --- /dev/null +++ b/.github/actions/publish/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:bionic + +LABEL "name"="Run make scripts and push changes" +LABEL "maintainer"="Winston Liu" +LABEL "version"="0.0.1" + +LABEL "com.github.actions.name"="Run make scripts and push changes" +LABEL "com.github.actions.description"="Run `make all` to post-process all files and then push changes" +LABEL "com.github.actions.icon"="package" +LABEL "com.github.actions.color"="green" + +RUN apt-get update > /dev/null && apt-get -yqq install git make pandoc astyle source-highlight > /dev/null + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/publish/entrypoint.sh b/.github/actions/publish/entrypoint.sh new file mode 100644 index 000000000..1391941ba --- /dev/null +++ b/.github/actions/publish/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +make all + +git add --all +staged_lines=`git diff --cached --numstat | wc -l` +if [ "$staged_lines "-eq "0" ]; then + exit 0 +fi + +git config --global user.name "Github Actions" + +git commit -m "Post-process files" + +git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} HEAD:master diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..2cba4ec10 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,17 @@ +name: Publish + +on: + push: + branches: + - master + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: ./.github/actions/publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From f016a4be1a7996d0bf9f72d4067ae3a9a505ef12 Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Thu, 9 Jan 2020 20:08:42 -0500 Subject: [PATCH 2/4] Make entrypoint.sh executable --- .github/actions/publish/entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/actions/publish/entrypoint.sh diff --git a/.github/actions/publish/entrypoint.sh b/.github/actions/publish/entrypoint.sh old mode 100644 new mode 100755 From 6e3c04e6d215b841d4ebda7388e289aa330d0818 Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Thu, 9 Jan 2020 20:19:43 -0500 Subject: [PATCH 3/4] Fixes --- .github/actions/publish/entrypoint.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/actions/publish/entrypoint.sh b/.github/actions/publish/entrypoint.sh index 1391941ba..451f88f47 100755 --- a/.github/actions/publish/entrypoint.sh +++ b/.github/actions/publish/entrypoint.sh @@ -4,12 +4,13 @@ make all git add --all staged_lines=`git diff --cached --numstat | wc -l` -if [ "$staged_lines "-eq "0" ]; then +if [ "$staged_lines" -eq "0" ]; then exit 0 fi -git config --global user.name "Github Actions" +git config user.name "Github Actions" +git config user.email "actions@github.com" git commit -m "Post-process files" -git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} HEAD:master +git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" HEAD:master From 15f0f3ec1430b5b12359673310e2530b288f1cd6 Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Thu, 9 Jan 2020 20:40:52 -0500 Subject: [PATCH 4/4] Ignore filemode The Makefile changes file permissions and we don't care about that --- .github/actions/publish/entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/publish/entrypoint.sh b/.github/actions/publish/entrypoint.sh index 451f88f47..6608952e4 100755 --- a/.github/actions/publish/entrypoint.sh +++ b/.github/actions/publish/entrypoint.sh @@ -2,6 +2,9 @@ make all +# Frankly, we don't care about file mode changes +git config core.filemode false + git add --all staged_lines=`git diff --cached --numstat | wc -l` if [ "$staged_lines" -eq "0" ]; then