Skip to content

Commit

Permalink
feat: Push branch option (#117)
Browse files Browse the repository at this point in the history
* 👔 Add branch name parameter from GitHub Actions

* 🔧 Add GitHub Actions input

* ✏️ Fix linter warnings

* 📝 Update readme for push branch option
  • Loading branch information
yamashush committed Jan 4, 2023
1 parent 6d1ded3 commit 159df73
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down
2 changes: 2 additions & 0 deletions docs/README.zh-tw.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
6 changes: 5 additions & 1 deletion src/utils/file-writer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import * as core from '@actions/core';
import {mkdirSync, writeFileSync, readdirSync} from 'fs';
import {ThemeMap} from '../const/theme';

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}/`;
Expand Down

0 comments on commit 159df73

Please sign in to comment.