From c4ba72ddd2149e638afbbb8a0a7d588f789f09a9 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Sat, 24 Aug 2019 13:04:49 +0200 Subject: [PATCH] first commit --- Dockerfile | 16 ++++++++++++++++ README.md | 37 +++++++++++++++++++++++++++++++++++++ action.yml | 14 ++++++++++++++ start.sh | 5 +++++ 4 files changed, 72 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 action.yml create mode 100755 start.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a2e6331 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM alpine + +LABEL "name"="git-push" +LABEL "maintainer"="Adam Dobrawy " +LABEL "version"="0.0.1" + +LABEL "com.github.actions.name"="cURL for GitHub Actions" +LABEL "com.github.actions.description"="Runs cURL in an Action" +LABEL "com.github.actions.icon"="upload-cloud" +LABEL "com.github.actions.color"="green" + +COPY README.md LICENSE start.sh / + +RUN apk add --no-cache git + +CMD ["/start.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..e800a3c --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# GitHub Action for Git Push + +The GitHub Actions for pushing to Git repository local changes authorizing using GitHub token. + + +## Usage + +### Example Workflow file + +An example workflow to authenticate with Google Cloud Platform: + +```yaml +jobs: + build: + runs-on: ubuntu-16.04 + steps: + - uses: actions/checkout@master +... + - run: npm install + - uses: actions/checkout@master +``` + +Subsequent actions in the workflow will then be able to use `gcloud` as that user ([see `cli` for examples](/cli)). + +### Secrets + +* `GCLOUD_AUTH` **Required** Base64 encoded service account key exported as JSON + - For information about service account keys please see the [Google Cloud docs](https://cloud.google.com/sdk/docs/authorizing) + - For information about using Secrets in Actions please see the [Actions docs](https://developer.github.com/actions/creating-workflows/storing-secrets/). + +Example on encoding from a terminal : `base64 ~/.json` + +## License + +The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). + +Container images built with this project include third party materials. See [THIRD_PARTY_NOTICE.md](THIRD_PARTY_NOTICE.md) for details. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..b7b0b59 --- /dev/null +++ b/action.yml @@ -0,0 +1,14 @@ +name: 'Git Push' +description: 'Pushing to Git repository local changes' +author: 'ad-m' +inputs: + repo-token: + description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}' + required: true + branch: + description: 'Destination branch to push changes' + required: false + default: 'master' +runs: + using: 'docker' + image: 'Dockerfile' \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..18e1322 --- /dev/null +++ b/start.sh @@ -0,0 +1,5 @@ +#!/bin/sh +echo "Push to branch $BRANCH"; + +header=$(echo -n "ad-m:$INPUT_REPO_TOKEN" | base64) +git -c http.extraheader="AUTHORIZATION: basic $header" push origin refs/remotes/origin/master:master; \ No newline at end of file