Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d403eb4
chore: remove redundant safe-directory configuration
jackton1 Jun 14, 2022
f0a42d4
Update README.md
jackton1 Jun 14, 2022
e69c0c0
Add deploy key functionality (#120)
ZPascal Jun 15, 2022
828ee9b
Fix removed code lines
ZPascal Jun 15, 2022
492de90
Merge pull request #129 from ad-m/add-wrongly-removed-code
ZPascal Jun 15, 2022
84236bd
Merge branch 'master' into patch-4
jackton1 Jun 16, 2022
e5f70b0
* Add force with lease support
ZPascal May 5, 2022
6195df7
Merge pull request #124 from ZPascal/add-force-with-lease-support
ZPascal Jun 25, 2022
67c1a68
fix: github_token and github_url optional
SevereCloud Jun 28, 2022
9a46ba8
Merge pull request #134 from SevereCloud/patch-1
ZPascal Jun 28, 2022
7e6f17c
Merge branch 'master' into patch-4
ZPascal Jun 30, 2022
bb3766a
Add atomic push
sleepypikachu Sep 2, 2022
c9ef0a9
Merge pull request #128 from jackton1/patch-4
ZPascal Oct 3, 2022
00483b0
Add option to control atomic switch
sleepypikachu Oct 4, 2022
35284cf
Merge pull request #138 from sleepypikachu/master
ZPascal Oct 4, 2022
b87afee
Use node16 to run action
kdambekalns Oct 11, 2022
4dcce6d
Merge pull request #140 from kdambekalns/patch-1
ZPascal Oct 12, 2022
552c074
Update the documentation and the push process (#135)
ZPascal Oct 31, 2022
0fafdd6
fix typo (#149)
LesnyRumcajs Dec 12, 2022
75ba9fb
fix: Remove the user (#156)
ZPascal May 18, 2023
c361e2b
Revert "fix: Remove the user (#156)" (#168)
ZPascal May 18, 2023
df39337
*fix: Remove the user (#169)
ZPascal May 21, 2023
d9117be
docs: Add protected branch support to the documentation (#171)
ZPascal Jun 6, 2023
f8e0bce
Update start.js (#175)
kerwin612 Jul 27, 2023
4150bf0
Revert "Update start.js (#175)" (#176)
ZPascal Jul 27, 2023
9a2e3c1
fix #177 (#178)
kerwin612 Jul 28, 2023
29f05e0
docs: Document Github App Token support (#180)
ZPascal Aug 27, 2023
d91a481
feat: Update the used NodeJS version to 20 (#184)
ZPascal Oct 7, 2023
c8e9166
docs: Adjust the PAT and protected branch documentation (#174)
ZPascal Dec 3, 2023
e0ae067
feat: Add push to submodules support (#155)
ZPascal Jan 10, 2024
fc0cf17
docs: Adjust the initial git write access documentation (#190)
ZPascal Jan 15, 2024
fcea099
fix: Update the documentation (#160)
ZPascal Jan 22, 2024
9870d48
Update the release process and setup the process to specify tags (#145)
ZPascal Mar 10, 2024
2ebd2b2
Issue 191 (#197)
ZPascal Jun 27, 2024
f17d07c
Add only push tags support (#154)
ZPascal Jun 27, 2024
77c5b41
docs: improve documentation and update image (#195)
jackton1 Jul 1, 2024
57116ac
docs: Remove the url link
ZPascal Nov 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ on:
jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Verify action syntax
# The action should not publish any real changes, but should succeed.
uses: './'
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
branch: '${{ github.ref }}'
- uses: actions/checkout@v4
- name: Verify action syntax
# The action should not publish any real changes, but should succeed.
uses: './'
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
branch: '${{ github.ref }}'
2 changes: 1 addition & 1 deletion .github/workflows/monitoring_link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Validate links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Validate links
uses: ad-m/report-link-action@master
with:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish

on:
release:
types: [ published ]

jobs:

publish:
name: Publish the release version
runs-on: ubuntu-latest

steps:
- name: Checkout the repository and the branch
uses: actions/checkout@v4

- name: Setup the release version and overwrite the existing major version tag
run: |
major_version=$(echo $GITHUB_REF_NAME | cut -d. -f1)
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag -fa $major_version -m "Update $major_version tag and add version $GITHUB_REF_NAME to it"
git push origin $major_version --force
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea/
279 changes: 257 additions & 22 deletions README.md

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ branding:
inputs:
github_token:
description: 'GitHub token or PAT token'
required: true
required: false
default: ${{ github.token }}
github_url:
description: 'GitHub url or GitHub Enterprise url'
required: true
required: false
default: ${{ github.server_url }}
ssh:
description: 'Specify if ssh should be used'
required: false
repository:
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
default: ''
Expand All @@ -23,13 +26,26 @@ inputs:
force:
description: 'Determines if force push is used'
required: false
force_with_lease:
description: 'Determines if force-with-lease push is used'
required: false
atomic:
description: 'Determines if atomic push is used, default true'
required: false
push_to_submodules:
description: 'Determines if --recurse-submodules=<strategy> is used. The value defines the used strategy'
required: false
default: 'on-demand'
tags:
description: 'Determines if --tags is used'
required: false
push_only_tags:
description: 'Determines if the action should only push the tags, default false'
required: false
directory:
description: 'Directory to change to before pushing.'
required: false
default: '.'
runs:
using: 'node12'
using: 'node20'
main: 'start.js'
Binary file added docs/images/Github_PAT_Fine_Gained.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Github_PAT_Private_Repo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Github_PAT_Public_Repo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/personal-acces-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Creation of a personal access token

1. Login to your GitHub account and navigate to the following [page](https://github.com/settings/tokens).
2. Click on the generate new token button and start the process to get a new token (classic or fine-gained)
- In the classic mode your token needs as a minimum requirement for private repositories, complete repo and admin read:org access. ![PAT Private Repo](images/Github_PAT_Private_Repo.jpeg)

- In the classic mode and you want to use it on public repositories, your token needs public_repo access. ![PAT Public Repo](images/Github_PAT_Public_Repo.jpeg)

- If you want to use a fine-gained token as minimum requirement, your token needs access to the repository, contents read/write, metadata read and actions read access. ![PAT Fine Gained](images/Github_PAT_Fine_Gained.jpeg)
3. Be aware, if you want to update GitHub workflow files, it's necessary that your token got workflow rights (read/write on fine-gained tokens).
12 changes: 6 additions & 6 deletions start.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict';
const spawn = require('child_process').spawn;
const path = require("path");
const path = require('path');
const http = require('http');
const https = require('https');

const get = (url, options = {}) => new Promise((resolve, reject) => https
const get = (url, options = {}) => new Promise((resolve, reject) => ((new URL(url).protocol === 'http:') ? http : https)
.get(url, options, (res) => {
const chunks = [];
res.on('data', (chunk) => chunks.push(chunk));
Expand Down Expand Up @@ -42,8 +43,8 @@ const trim = (value, charlist) => trimLeft(trimRight(value, charlist));
const main = async () => {
let branch = process.env.INPUT_BRANCH;
const repository = trim(process.env.INPUT_REPOSITORY || process.env.GITHUB_REPOSITORY);
const github_url_protocol = trim(process.env.INPUT_GITHUB_URL).split("//")[0];
const github_url = trim(process.env.INPUT_GITHUB_URL).split("//")[1];
const github_url_protocol = trim(process.env.INPUT_GITHUB_URL).split('//')[0];
const github_url = trim(process.env.INPUT_GITHUB_URL).split('//')[1];
if (!branch) {
const headers = {
'User-Agent': 'github.com/ad-m/github-push-action'
Expand All @@ -65,6 +66,5 @@ const main = async () => {

main().catch(err => {
console.error(err);
console.error(err.stack);
process.exit(err.code || -1);
process.exit(-1);
})
52 changes: 44 additions & 8 deletions start.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,29 +1,65 @@
#!/bin/sh
set -e

INPUT_ATOMIC=${INPUT_ATOMIC:-true}
INPUT_FORCE=${INPUT_FORCE:-false}
INPUT_FORCE_WITH_LEASE=${INPUT_FORCE_WITH_LEASE:-false}
INPUT_SSH=${INPUT_SSH:-false}
INPUT_TAGS=${INPUT_TAGS:-false}
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
_FORCE_OPTION=''
INPUT_PUSH_ONLY_TAGS=${INPUT_PUSH_ONLY_TAGS:-false}
INPUT_DIRECTORY=${INPUT_DIRECTORY:-"."}
INPUT_PUSH_TO_SUBMODULES=${INPUT_PUSH_TO_SUBMODULES:-""}
_ATOMIC_OPTION=""
_FORCE_OPTION=""
REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}

echo "Push to branch $INPUT_BRANCH";
[ -z "${INPUT_GITHUB_TOKEN}" ] && {
echo 'Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}".';
echo "Missing input 'github_token: ${{ secrets.GITHUB_TOKEN }}'.";
exit 1;
};

if ${INPUT_FORCE} && ${INPUT_FORCE_WITH_LEASE}; then
echo "Please, specify only force or force_with_lease and not both.";
exit 1;
fi

if ${INPUT_ATOMIC}; then
_ATOMIC_OPTION="--atomic"
fi

if ${INPUT_FORCE}; then
_FORCE_OPTION='--force'
_FORCE_OPTION="--force"
fi

if ${INPUT_FORCE_WITH_LEASE}; then
_FORCE_OPTION="--force-with-lease"
fi

if ${INPUT_TAGS}; then
_TAGS='--tags'
_TAGS="--tags"
fi

if [ -n "${INPUT_PUSH_TO_SUBMODULES}" ]; then
_INPUT_PUSH_TO_SUBMODULES="--recurse-submodules=${INPUT_PUSH_TO_SUBMODULES}"
fi

cd ${INPUT_DIRECTORY}

remote_repo="${INPUT_GITHUB_URL_PROTOCOL}//${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@${INPUT_GITHUB_URL}/${REPOSITORY}.git"
git config --local --add safe.directory ${INPUT_DIRECTORY}
if ${INPUT_SSH}; then
remote_repo="git@${INPUT_GITHUB_URL}:${REPOSITORY}.git"
else
remote_repo="${INPUT_GITHUB_URL_PROTOCOL}//oauth2:${INPUT_GITHUB_TOKEN}@${INPUT_GITHUB_URL}/${REPOSITORY}.git"
fi

if ! ${INPUT_FORCE_WITH_LEASE}; then
ADDITIONAL_PARAMETERS="${remote_repo} HEAD:${INPUT_BRANCH}"
elif ${INPUT_PUSH_ONLY_TAGS}; then
ADDITIONAL_PARAMETERS="${remote_repo}"
fi

if ${INPUT_FORCE_WITH_LEASE} && ${INPUT_TAGS}; then
_ATOMIC_OPTION=""
fi

git push "${remote_repo}" HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION $_TAGS;
git push $ADDITIONAL_PARAMETERS $_INPUT_PUSH_TO_SUBMODULES $_ATOMIC_OPTION --follow-tags $_FORCE_OPTION $_TAGS;