Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Push branch option #117

Merged
merged 4 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
```
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