From fdf062fc1c7d8cfbbdadf8a0dab388609d39bedc Mon Sep 17 00:00:00 2001
From: Stefan Zweifel <hello@stefanzweifel.io>
Date: Tue, 27 Aug 2019 20:26:44 +0200
Subject: [PATCH] Switch to branch and setup remote origin

---
 README.md     | 1 +
 entrypoint.sh | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/README.md b/README.md
index 23ba55a..e4e5f24 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,7 @@ New GitHub Actions syntax:
     commit_author_name: John Doe
     commit_message: Apply automatic changes
   env:
+    TOKEN: ${{ secrets.TOKEN }} # Personal Access Token
     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 ```
 
diff --git a/entrypoint.sh b/entrypoint.sh
index df9287d..073ed4a 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -1,6 +1,12 @@
 #!/bin/sh
 set -eu
 
+# Switch to branch from current Workflow run
+git switch "${GITHUB_REF:11}"
+
+# Set origin URL
+git remote set-url origin https://$TOKEN:x-oauth-basic@github.com/$GITHUB_REPOSITORY
+
 git config --global user.email "actions@github.com"
 git config --global user.name "GitHub Actions"