diff --git a/README.md b/README.md index 10abab488..d841bc0d3 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.SUMMARY_GITHUB_TOKEN }} with: USERNAME: ${{ github.repository_owner }} + # BRANCH_NAME is optional, default to main, branch name to push cards + BRANCH_NAME: "main" # UTC_OFFSET is optional, default to zero UTC_OFFSET: 8 # EXCLUDE is an optional comma seperated list of languages to exclude, defaults to "" diff --git a/action.yml b/action.yml index 6c26c3406..ea3017d1f 100644 --- a/action.yml +++ b/action.yml @@ -7,6 +7,10 @@ inputs: required: true description: 'GitHub username' default: ${{ github.repository_owner }} + BRANCH_NAME: + required: false + description: 'The branch to push cards' + default: 'main' UTC_OFFSET: required: false description: 'The UTC offset used in the Productive Time Card.(e.g., 8, -3)' diff --git a/docs/README.zh-tw.md b/docs/README.zh-tw.md index f3471f155..67fa20c01 100644 --- a/docs/README.zh-tw.md +++ b/docs/README.zh-tw.md @@ -92,6 +92,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.SUMMARY_GITHUB_TOKEN }} with: USERNAME: ${{ github.repository_owner }} + # BRANCH_NAME is optional, default to main, branch name to push cards + BRANCH_NAME: "main" # UTC_OFFSET is optional, default to zero UTC_OFFSET: 8 ``` diff --git a/src/utils/file-writer.ts b/src/utils/file-writer.ts index 35068c3f4..2e42e23f0 100644 --- a/src/utils/file-writer.ts +++ b/src/utils/file-writer.ts @@ -1,3 +1,4 @@ +import * as core from '@actions/core'; import {mkdirSync, writeFileSync, readdirSync} from 'fs'; import {ThemeMap} from '../const/theme'; @@ -5,7 +6,10 @@ export const OUTPUT_PATH = './profile-summary-card-output/'; const GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY; // If neither a branch or tag is available for the event type, the variable will not exist. https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables -const GITHUB_BRANCH = process.env.GITHUB_REF == undefined ? 'main' : process.env.GITHUB_REF.split('/').pop(); +const GITHUB_BRANCH = + process.env.GITHUB_REF == undefined + ? core.getInput('BRANCH_NAME', {required: false}) + : process.env.GITHUB_REF.split('/').pop(); export const writeSVG = function (folder: string, filename: string, svgString: string) { const targetFolder = `${OUTPUT_PATH}${folder}/`;