Skip to content

Commit

Permalink
Merge pull request #16 from tdonaworth/add-GIT-URL-variable
Browse files Browse the repository at this point in the history
Add git url variable
  • Loading branch information
varunsridharan authored Jul 21, 2021
2 parents decdb07 + 4f6b2ad commit 3751721
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This also isn't limited to Github Action yaml files - another use case could be
| **Argument** | Defaults | Description |
| --- | :---: | :---: |
| `GITHUB_TOKEN` | - | **Required** Token to use to get repos and write secrets. `${{secrets.GITHUB_TOKEN}}` will not work. instead **Personal Access Token Required*** |
| `GIT_URL` | github.com | URL for the instance of github, where repositories should be searched for. Change if using a GHES instance. |
| `REPOSITORIES` | - | **Required** New line deliminated regex expressions to select repositories. Repositires are limited to those in whcich the token user is an owner or collaborator. |
| `WORKFLOW_FILES` | - | **Required** New line deliminated regex expressions. workflow files to be copied to provided repositores |
| `DRY_RUN` | ***false*** | Run everything except for nothing will be pushed. |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
GITHUB_TOKEN:
description: "Token to use to get repos and write secrets"
required: true
GIT_URL:
description: "The URL to the Github server. Defaults to github.com. Change if using a GHES instance."
default: 'github.com'
required: false
DRY_RUN:
description: "Run everything except for nothing will be Updated."
required: false
Expand Down
5 changes: 3 additions & 2 deletions src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const toolkit = require( 'actions-js-toolkit' );

const repositoryDetails = ( input_repo ) => {
let GIT_TOKEN = require( './variables' ).GITHUB_TOKEN;
let GIT_URL = require( './variables' ).GIT_URL;
let WORKSPACE = require( './variables' ).WORKSPACE;
input_repo = input_repo.split( '@' );

Expand All @@ -14,7 +15,7 @@ const repositoryDetails = ( input_repo ) => {
return {
owner: input_repo[ 0 ],
repository: input_repo[ 1 ],
git_url: `https://x-access-token:${GIT_TOKEN}@github.com/${input_repo[ 0 ]}/${input_repo[ 1 ]}.git`,
git_url: `https://x-access-token:${GIT_TOKEN}@${GIT_URL}/${input_repo[ 0 ]}/${input_repo[ 1 ]}.git`,
branch,
local_path: `${WORKSPACE}${input_repo[ 0 ]}/${input_repo[ 1 ]}/${branch}/`
};
Expand Down Expand Up @@ -171,4 +172,4 @@ module.exports = {
repositoryClone: repositoryClone,
source_file_location: source_file_location,
extract_workflow_file_info: extract_workflow_file_info,
};
};
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ async function run() {
let COMMIT_EACH_FILE = require( './variables' ).COMMIT_EACH_FILE;
let DRY_RUN = require( './variables' ).DRY_RUN;
let GITHUB_TOKEN = require( './variables' ).GITHUB_TOKEN;
let GIT_URL = require( './variables' ).GIT_URL;
let WORKFLOW_FILES_DIR = require( './variables' ).WORKFLOW_FILES_DIR;
let WORKSPACE = require( './variables' ).WORKSPACE;
let REPOSITORIES = require( './variables' ).REPOSITORIES;
Expand Down Expand Up @@ -170,4 +171,4 @@ async function run() {
} );
}

run();
run();
4 changes: 3 additions & 1 deletion src/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const DRY_RUN = toolkit.input.tobool( core.getInput( 'DRY_RUN' )
const PULL_REQUEST = toolkit.input.tobool( core.getInput( 'PULL_REQUEST' ) );
const SKIP_CI = toolkit.input.tobool( core.getInput( 'SKIP_CI' ) );
const GITHUB_TOKEN = core.getInput( 'GITHUB_TOKEN' );
const GIT_URL = core.getInput( 'GIT_URL' );
const RAW_REPOSITORIES = core.getInput( 'REPOSITORIES' );
const COMMIT_MESSAGE = core.getInput( 'COMMIT_MESSAGE' );
const RAW_WORKFLOW_FILES = core.getInput( 'WORKFLOW_FILES' );
Expand All @@ -23,6 +24,7 @@ module.exports = {
COMMIT_EACH_FILE,
DRY_RUN,
GITHUB_TOKEN,
GIT_URL,
RAW_REPOSITORIES,
PULL_REQUEST,
RAW_WORKFLOW_FILES,
Expand All @@ -33,4 +35,4 @@ module.exports = {
GITHUB_WORKSPACE,
SKIP_CI,
COMMIT_MESSAGE
};
};

0 comments on commit 3751721

Please sign in to comment.