Skip to content

Commit

Permalink
replace adrianjost/files-sync-action
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Mar 7, 2024
1 parent b800f6a commit 38e8932
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ jobs:
${{ github.event_name == 'pull_request' && 'false' || 'true' }}
github_token: ${{ secrets.GITHUB_TOKEN }} # can use GITHUB_TOKEN for read-only access

- name: Modify Homebrew Formula
# ensure the file is unique
run: |
echo "# Created from ${{ github.repository }}@${{ github.sha }}" >> ./tests/Formula/hello_world.rb
- name: Run Action
id: action
uses: ./
with:
git_email: ${{ secrets.GH_BOT_EMAIL }}
git_username: ${{ secrets.GH_BOT_NAME }}
src_root: /tests/
target_repo: ${{ github.repository }}:tests
local_repo_directory: ${{ github.workspace }}/tests
target_repo: ${{ github.repository }}
target_repo_branch: tests
token: ${{ secrets.GH_BOT_TOKEN }}

- name: Create/Update GitHub Release
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
A reusable action to publish homebrew formulas to a tap.
This action is tailored to the @LizardByte organization, but can be used by anyone if they follow the same conventions.

This is basically a wrapper around [adrianjost/files-sync-action](https://github.com/adrianjost/files-sync-action),
with some different defaults to make it easier to use within the @LizardByte organization.

## Basic Usage

See [action.yml](action.yml)

The intent here is that the formulas are build in the upstream repository, instead of the tap repository.
The intent here is that the formulas are built in the upstream repository, instead of the tap repository.

As part of an automated release workflow, this action can be used to upload the built formulas to the tap repository.

Expand All @@ -33,13 +30,10 @@ steps:
- name: Publish Homebrew Formula
uses: LizardByte/homebrew-release-action@master
with:
file_patterns: |-
^Aliases/*$
^Formula/*.rb$
local_repo_directory: "${{ github.workspace }}/homebrew-repo"
git_email: ${{ secrets.GIT_EMAIL }}
git_username: ${{ secrets.GIT_USERNAME }}
skip_delete: true
src_root: /build/ # do not include GitHub workspace, also must end with a trailing slash
target_repo: repo_owner/repo_name
target_repo_branch: master
token: ${{ secrets.PAT }}
```
58 changes: 36 additions & 22 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,58 @@ name: "Homebrew Release"
description: "A reusable action to publish a Homebrew formula to a tap."
author: "LizardByte"
inputs:
file_patterns:
description: 'The file patterns to publish.'
default: |-
^Formula/*.rb$
local_repo_directory:
description: 'The location of the local directory. If the default is not used, you must pass the entire path.'
default: "homebrew"
required: false
git_email:
description: 'The email to use for the commit.'
required: true
git_username:
description: 'The username to use for the commit.'
required: true
skip_delete:
description: 'Skip deleting formulas in the target repo, that do not exist in the source repo.'
default: 'false'
required: false
src_root:
description: 'Prepend this to the file patterns.'
default: '/'
required: false
target_repo:
description: 'The target repository to publish to.'
default: 'LizardByte/homebrew'
required: false
target_repo_branch:
description: 'The target repository branch to publish to.'
default: ''
required: false
token:
description: 'Github Token.'
required: true

runs:
using: "composite"
steps:
- name: Homebrew Release
uses: adrianjost/[email protected]
- name: Checkout database
uses: actions/checkout@v4
with:
repository: ${{ inputs.target_repo }}
ref: ${{ inputs.target_repo_branch }}
path: ${{ github.action_path }}/build
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo

- name: Prepare Homebrew repo
shell: bash
run: |
if [ "${{ inputs.local_repo_directory }}" == "homebrew" ]; then
source_path="${{ github.workspace }}/${{ inputs.local_repo_directory }}"
else
source_path="${{ inputs.local_repo_directory }}"
fi
# copy local repo to target repo
cp -f -r ${source_path}/. ${{ github.action_path }}/build/
- name: GitHub Commit & Push
uses: actions-js/[email protected]
with:
COMMIT_MESSAGE: "Update ${{ github.repository }} to ${{ github.sha }}"
FILE_PATTERNS: ${{ inputs.file_patterns }}
GIT_EMAIL: ${{ inputs.git_email }}
GIT_USERNAME: ${{ inputs.git_username }}
GITHUB_TOKEN: ${{ inputs.token }}
SKIP_DELETE: ${{ inputs.skip_delete }}
SRC_ROOT: ${{ inputs.src_root }}
TARGET_REPOS: ${{ inputs.target_repo }}
author_email: ${{ inputs.git_email }}
author_name: ${{ inputs.git_username }}
branch: ${{ inputs.target_repo_branch }} # commit to target branch
directory: ${{ github.action_path }}/build # use the build directory
github_token: ${{ inputs.token }}
message: "Update ${{ github.repository }} to ${{ github.sha }}"

0 comments on commit 38e8932

Please sign in to comment.