Skip to content

Commit

Permalink
fix: ensure checkout paths must are under github workspace (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored Mar 9, 2024
1 parent 21baeae commit adfde6c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ to point to a different repository if you are not using the official Homebrew/ho

```yaml
steps:
- name: Publish Homebrew Formula
- name: Validate and Publish Homebrew Formula
uses: LizardByte/homebrew-release-action@master
with:
formula_file: "${{ github.workspace }}/hello_world.rb"
Expand All @@ -36,7 +36,7 @@ It's possible to overwrite the defaults by providing additional inputs:
```yaml
steps:
- name: Publish Homebrew Formula
- name: Validate and Publish Homebrew Formula
uses: LizardByte/homebrew-release-action@master
with:
contribute_to_homebrew_core: true
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
run: |
# whatever you need to do to generate the formula
- name: Publish Homebrew Formula
- name: Validate and Publish Homebrew Formula
uses: LizardByte/homebrew-release-action@master
with:
formula_file: "${{ github.workspace }}/build/hello_world.rb"
Expand Down
12 changes: 6 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "Homebrew Release"
description: "A reusable action to publish a Homebrew formula to a tap."
description: "A reusable action to audit, install, test, and publish a Homebrew formula."
author: "LizardByte"
inputs:
contribute_to_homebrew_core:
Expand Down Expand Up @@ -97,7 +97,7 @@ runs:
with:
repository: ${{ inputs.org_homebrew_repo }}
ref: ${{ inputs.org_homebrew_repo_branch }}
path: ${{ github.action_path }}/org_homebrew_repo
path: ${{ github.workspace }}/homebrew-release-action/org_homebrew_repo
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 1

Expand All @@ -106,7 +106,7 @@ runs:
uses: actions/checkout@v4
with:
repository: ${{ inputs.homebrew_core_fork_repo }}
path: ${{ github.action_path }}/homebrew_core_fork_repo
path: ${{ github.workspace }}/homebrew-release-action/homebrew_core_fork_repo
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 1

Expand Down Expand Up @@ -138,7 +138,7 @@ runs:
author_email: ${{ inputs.git_email }}
author_name: ${{ inputs.git_username }}
branch: ${{ inputs.org_homebrew_repo_branch }} # commit to target branch
directory: ${{ github.action_path }}/org_homebrew_repo
directory: ${{ github.workspace }}/homebrew-release-action/org_homebrew_repo
github_token: ${{ inputs.token }}
message: "Update ${{ github.repository }} to ${{ github.sha }}"
repository: ${{ inputs.org_homebrew_repo }}
Expand All @@ -150,7 +150,7 @@ runs:
author_email: ${{ inputs.git_email }}
author_name: ${{ inputs.git_username }}
branch: ${{ steps.homebrew-tests.outputs.homebrew_core_branch }}
directory: ${{ github.action_path }}/homebrew_core_fork_repo
directory: ${{ github.workspace }}/homebrew-release-action/homebrew_core_fork_repo
force: true # need to force since the branch is sometimes reset
github_token: ${{ inputs.token }}
message: "Update ${{ github.repository }} to ${{ github.sha }}"
Expand All @@ -161,7 +161,7 @@ runs:
GH_TOKEN: ${{ inputs.token }}
if: ${{ inputs.contribute_to_homebrew_core == 'true' && inputs.publish == 'true' }}
shell: bash
working-directory: ${{ github.action_path }}/homebrew_core_fork_repo
working-directory: ${{ github.workspace }}/homebrew-release-action/homebrew_core_fork_repo
run: |
# Check if a pull request already exists with the same head branch
PR_EXISTS=$(gh pr list \
Expand Down
6 changes: 4 additions & 2 deletions action/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ def process_input_formula(formula_file: str) -> str:
capture_output=True
)

org_homebrew_repo = os.path.join(os.environ['GITHUB_ACTION_PATH'], 'org_homebrew_repo')
homebrew_core_fork_repo = os.path.join(os.environ['GITHUB_ACTION_PATH'], 'homebrew_core_fork_repo')
org_homebrew_repo = os.path.join(
os.environ['GITHUB_WORKSPACE'], 'homebrew-release-action', 'org_homebrew_repo')
homebrew_core_fork_repo = os.path.join(
os.environ['GITHUB_WORKSPACE'], 'homebrew-release-action', 'homebrew_core_fork_repo')
print(f'org_homebrew_repo: {org_homebrew_repo}')
print(f'homebrew_core_fork_repo: {homebrew_core_fork_repo}')

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def operating_system():

@pytest.fixture(scope='function') # todo: fix repo deletion
def homebrew_core_fork_repo():
directory = os.environ['GITHUB_ACTION_PATH']
directory = os.path.join(os.environ['GITHUB_WORKSPACE'], 'homebrew-release-action')
os.makedirs(directory, exist_ok=True)

repo = 'homebrew_core_fork_repo'
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def test_proces_input_formula():
assert formula == 'hello_world'

dirs = [
os.path.join(os.environ['GITHUB_ACTION_PATH'], 'org_homebrew_repo'),
os.path.join(os.environ['GITHUB_ACTION_PATH'], 'homebrew_core_fork_repo'),
os.path.join(os.environ['GITHUB_WORKSPACE'], 'homebrew-release-action', 'org_homebrew_repo'),
os.path.join(os.environ['GITHUB_WORKSPACE'], 'homebrew-release-action', 'homebrew_core_fork_repo'),
]

for d in dirs:
Expand Down

0 comments on commit adfde6c

Please sign in to comment.