From 7ee318634e6e3e9ee23ab9e8d452d132b149010f Mon Sep 17 00:00:00 2001 From: Aram Zucker-Scharff Date: Wed, 1 Jun 2022 18:26:46 -0400 Subject: [PATCH 1/3] Add git-lfs to setup. --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 29040d4dc..1cb29fce9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN apt-get update && \ curl \ wget \ ssh \ + git-lfs \ vim && \ apt-get autoclean && \ apt-get clean && \ @@ -19,7 +20,8 @@ RUN apt-get update && \ RUN git --version && \ git config --global init.defaultBranch main && \ - git config --global init.defaultBranch + git config --global init.defaultBranch && \ + git lfs install WORKDIR /node ARG NODE_VERSION From d70eea0bbf9445127b4e27be3eb822c0381c67f4 Mon Sep 17 00:00:00 2001 From: Aram Zucker-Scharff Date: Mon, 6 Jun 2022 11:37:52 -0400 Subject: [PATCH 2/3] 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. --- .editorconfig | 3 +++ Dockerfile | 4 +--- README.md | 38 ++++++++++++++++++++++++++++++++++++++ action.yml | 4 ++++ src/get-inputs.ts | 4 ++++ src/interfaces.ts | 1 + src/main.ts | 3 +++ 7 files changed, 54 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 39abb037c..fae9d87dd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,6 @@ trim_trailing_whitespace = true [Makefile] indent_size = 4 indent_style = tab + +[Dockerfile] +indent_size = 4 diff --git a/Dockerfile b/Dockerfile index 1cb29fce9..29040d4dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index 4491ed6a4..8b03cd3bb 100644 --- a/README.md +++ b/README.md @@ -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 Back to TOC ☝️ +### ⭐️ 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 diff --git a/action.yml b/action.yml index 14ad0671f..1d3bcb436 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/src/get-inputs.ts b/src/get-inputs.ts index 164f43351..7afc4d815 100644 --- a/src/get-inputs.ts +++ b/src/get-inputs.ts @@ -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'), diff --git a/src/interfaces.ts b/src/interfaces.ts index d1a615dca..b10ceb099 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -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; diff --git a/src/main.ts b/src/main.ts index 6ddf944ba..61c77e14d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,6 +55,9 @@ export async function run(): Promise { 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) { From a37c04945f88e38c2954afe4356d26300ef3d7b3 Mon Sep 17 00:00:00 2001 From: Aram Zucker-Scharff Date: Mon, 6 Jun 2022 11:45:41 -0400 Subject: [PATCH 3/3] Add test coverage for LFS input --- __tests__/get-inputs.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/__tests__/get-inputs.test.ts b/__tests__/get-inputs.test.ts index 2cd306a9d..41521d343 100644 --- a/__tests__/get-inputs.test.ts +++ b/__tests__/get-inputs.test.ts @@ -56,6 +56,7 @@ function getInputsLog(authMethod: string, inps: Inputs): string { [INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll} [INFO] CNAME: ${inps.CNAME} [INFO] ExcludeAssets ${inps.ExcludeAssets} +[INFO] Lfs: ${inps.Lfs} `; } @@ -125,6 +126,7 @@ describe('getInputs()', () => { expect(inps.DisableNoJekyll).toBe(false); expect(inps.CNAME).toMatch(''); expect(inps.ExcludeAssets).toMatch('.github'); + expect(inps.Lfs).toBe(false); }); test('get spec inputs', () => { @@ -147,6 +149,7 @@ describe('getInputs()', () => { process.env['INPUT_DISABLE_NOJEKYLL'] = 'true'; process.env['INPUT_CNAME'] = 'github.com'; process.env['INPUT_EXCLUDE_ASSETS'] = '.github'; + process.env['INPUT_LFS'] = 'false'; const inps: Inputs = getInputs(); @@ -169,6 +172,7 @@ describe('getInputs()', () => { expect(inps.DisableNoJekyll).toBe(true); expect(inps.CNAME).toMatch('github.com'); expect(inps.ExcludeAssets).toMatch('.github'); + expect(inps.Lfs).toBe(false); }); test('get spec inputs enable_jekyll', () => {