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

Add git-lfs to setup process #758

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove mistaken Docker command, use git-lfs in setup
This change sets up Git LFS using the same approach as @actions/checkout
and will hopefully allow the use of Git LFS to match the potential use
in the checkout action and allow users to push up published GitHub
pages using `git lfs` to support files larger than 100MB.
  • Loading branch information
AramZS committed Jun 6, 2022
commit d70eea0bbf9445127b4e27be3eb822c0381c67f4
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -11,3 +11,6 @@ trim_trailing_whitespace = true
[Makefile]
indent_size = 4
indent_style = tab

[Dockerfile]
indent_size = 4
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ RUN apt-get update && \
curl \
wget \
ssh \
git-lfs \
vim && \
apt-get autoclean && \
apt-get clean && \
@@ -20,8 +19,7 @@ RUN apt-get update && \

RUN git --version && \
git config --global init.defaultBranch main && \
git config --global init.defaultBranch && \
git lfs install
git config --global init.defaultBranch

WORKDIR /node
ARG NODE_VERSION
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ Note that the `GITHUB_TOKEN` that is created by the runner might not inherently
- [⭐️ Set Git username and email](#%EF%B8%8F-set-git-username-and-email)
- [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message)
- [⭐️ Create Git tag](#%EF%B8%8F-create-git-tag)
- [⭐️ Upload large files with Git LFS](#%EF%B8%8F-upload-large-files-with-git-lfs)
- [Tips and FAQ](#tips-and-faq)
- [⭐️ Create SSH Deploy Key](#%EF%B8%8F-create-ssh-deploy-key)
- [⭐️ First Deployment with `GITHUB_TOKEN`](#%EF%B8%8F-first-deployment-with-github_token)
@@ -523,7 +524,44 @@ v1.2.3 # Tag on the main branch
<a href="#table-of-contents">Back to TOC ☝️</a>
</div>

### ⭐️ Upload large files with Git LFS

If you are using [Git LFS](https://git-lfs.github.com/) as an option to manage files larger than 100MB in your repository, you can push these to the deployed site.

It is expected that you would run your checkout action with `lfs` enabled (see below for an example).

You will also need to make sure that your build tool includes the `.gitattributes` file in its output.

```yaml
name: GitHub Pages

on:
push:
branches:
- main
tags:
- 'v*.*.*'

jobs:
deploy:
runs-on: ubuntu-20.04
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout
- uses: actions/checkout@v3
with:
lfs: 'true'

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
lfs: 'true'
```

## Tips and FAQ

4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -77,3 +77,7 @@ inputs:
description: 'Set files or directories to exclude from a publish directory.'
required: false
default: '.github'
lfs:
description: 'Whether to use Git-LFS to upload files'
required: false
default: 'false'
4 changes: 4 additions & 0 deletions src/get-inputs.ts
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ export function showInputs(inps: Inputs): void {
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
[INFO] ExcludeAssets ${inps.ExcludeAssets}
[INFO] Lfs: ${inps.Lfs}
`);
}

@@ -48,9 +49,12 @@ export function getInputs(): Inputs {
useBuiltinJekyll = true;
}

const enableLfs: boolean = isBoolean(core.getInput('lfs'));

const inps: Inputs = {
DeployKey: core.getInput('deploy_key'),
GithubToken: core.getInput('github_token'),
Lfs: enableLfs,
PersonalToken: core.getInput('personal_token'),
PublishBranch: core.getInput('publish_branch'),
PublishDir: core.getInput('publish_dir'),
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface Inputs {
readonly DeployKey: string;
readonly GithubToken: string;
readonly Lfs: boolean;
readonly PersonalToken: string;
readonly PublishBranch: string;
readonly PublishDir: string;
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -55,6 +55,9 @@ export async function run(): Promise<void> {
core.endGroup();

core.startGroup('Setup Git config');
if (inps.Lfs) {
await exec.exec('git', ['lfs', 'install', '--local']);
}
try {
await exec.exec('git', ['remote', 'rm', 'origin']);
} catch (e) {