Skip to content

Commit fa84826

Browse files
committed
🧪 Use prefetched action to make trampoline
Previously, the action repository was being cloned from the remote twice, unnecessarily. This patch eliminates this step and uses the copy that was checked out on job start. The generated trampoline action is still copied into the allowlisted working directory so it can be referenced by the relative path starting with `./`.
1 parent 0d02f37 commit fa84826

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

action.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,17 @@ runs:
130130
PR_REF: ${{ github.event.pull_request.head.ref }}
131131
PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
132132
PR_REPO_ID: ${{ github.event.pull_request.base.repo.id }}
133-
- name: Check out action repo
134-
uses: actions/checkout@v4
135-
with:
136-
path: action-repo
137-
ref: ${{ steps.set-repo-and-ref.outputs.ref }}
138-
repository: ${{ steps.set-repo-and-ref.outputs.repo }}
139133
- name: Create Docker container action
140134
run: |
141135
# Create Docker container action
142-
python create-docker-action.py
136+
python ${{ github.action_path }}/create-docker-action.py
143137
env:
144138
REF: ${{ steps.set-repo-and-ref.outputs.ref }}
145139
REPO: ${{ steps.set-repo-and-ref.outputs.repo }}
146140
REPO_ID: ${{ steps.set-repo-and-ref.outputs.repo-id }}
147141
shell: bash
148-
working-directory: action-repo
149142
- name: Run Docker container
150-
uses: ./action-repo/.github/actions/run-docker-container
143+
uses: ./.github/.tmp/.generated-actions/run-pypi-publish-in-docker-container
151144
with:
152145
user: ${{ inputs.user }}
153146
password: ${{ inputs.password }}

create-docker-action.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
REPO_ID = os.environ['REPO_ID']
1111
REPO_ID_GH_ACTION = '178055147'
1212

13+
ACTION_SHELL_CHECKOUT_PATH = pathlib.Path(__file__).parent.resolve()
14+
1315

1416
def set_image(ref: str, repo: str, repo_id: str) -> str:
1517
if repo_id == REPO_ID_GH_ACTION:
16-
return '../../../Dockerfile'
18+
return str(ACTION_SHELL_CHECKOUT_PATH / 'Dockerfile')
1719
docker_ref = ref.replace('/', '-')
1820
return f'docker://ghcr.io/{repo}:{docker_ref}'
1921

@@ -70,6 +72,9 @@ def set_image(ref: str, repo: str, repo_id: str) -> str:
7072
},
7173
}
7274

73-
action_path = pathlib.Path('.github/actions/run-docker-container/action.yml')
75+
action_path = pathlib.Path(
76+
'.github/.tmp/.generated-actions/'
77+
'run-pypi-publish-in-docker-container/action.yml',
78+
)
7479
action_path.parent.mkdir(parents=True, exist_ok=True)
7580
action_path.write_text(json.dumps(action, ensure_ascii=False), encoding='utf-8')

0 commit comments

Comments
 (0)