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

fix endless loop with action cache #483

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public async Task<IActionResult> Get(Guid scopeIdentifier, string hubName, Guid
var islocalcheckout = string.Equals(item.NameWithOwner, localcheckout, StringComparison.OrdinalIgnoreCase);
var name = $"{item.NameWithOwner}@{item.Ref}";
if(islocalcheckout && (item.Ref == BuildConstants.Source.CommitHash || !item.Ref.StartsWith(BuildConstants.Source.CommitHash)) ) {
actions[name] = new ActionDownloadInfo() {NameWithOwner = item.NameWithOwner, Ref = item.Ref, ResolvedNameWithOwner = item.NameWithOwner, TarballUrl = new Uri(new Uri(ServerUrl), item.Ref == BuildConstants.Source.CommitHash ? "localcheckout.tar.gz" : $"_apis/v1/ActionDownloadInfo/localcheckout?format=tarball&version={Uri.EscapeDataString(item.Ref)}&name={Uri.EscapeDataString(localcheckout)}").ToString(), ZipballUrl = new Uri(new Uri(ServerUrl), item.Ref == BuildConstants.Source.CommitHash ? "localcheckout.zip" : $"_apis/v1/ActionDownloadInfo/localcheckout?format=zipball&version={Uri.EscapeDataString(item.Ref)}&name={Uri.EscapeDataString(localcheckout)}").ToString(), ResolvedSha = GitHub.Runner.Sdk.BuildConstants.Source.CommitHash };
actions[name] = new ActionDownloadInfo() {NameWithOwner = item.NameWithOwner, Ref = item.Ref, ResolvedNameWithOwner = item.NameWithOwner, TarballUrl = new Uri(new Uri(ServerUrl), item.Ref == BuildConstants.Source.CommitHash ? "localcheckout.tar.gz" : $"_apis/v1/ActionDownloadInfo/localcheckout?format=tarball&version={Uri.EscapeDataString(item.Ref)}&name={Uri.EscapeDataString(localcheckout)}").ToString(), ZipballUrl = new Uri(new Uri(ServerUrl), item.Ref == BuildConstants.Source.CommitHash ? "localcheckout.zip" : $"_apis/v1/ActionDownloadInfo/localcheckout?format=zipball&version={Uri.EscapeDataString(item.Ref)}&name={Uri.EscapeDataString(localcheckout)}").ToString(), ResolvedSha = item.Ref != BuildConstants.Source.CommitHash ? GitHub.Runner.Sdk.BuildConstants.Source.CommitHash : $"{GitHub.Runner.Sdk.BuildConstants.Source.CommitHash}${item.Ref}" };
} else {
if(!string.IsNullOrEmpty(localcheckout) && !string.IsNullOrEmpty(runid) && long.TryParse(runid, out var _runid)) {
var handler = new MessageController(Configuration, this._cache, null, null);
Expand Down
91 changes: 89 additions & 2 deletions src/Runner.Server/localcheckout_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@ inputs:
Personal access token (PAT) used to fetch the repository. The PAT is configured
with the local git config, which enables your scripts to run authenticated git
commands. The post-job step removes the PAT.


We recommend using a service account with the least permissions necessary.
Also when generating a new PAT, select the least scopes necessary.


[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
default: ${{ github.token }}
ssh-key:
description: >
SSH key used to fetch the repository. The SSH key is configured with the local
git config, which enables your scripts to run authenticated git commands.
The post-job step removes the SSH key.


We recommend using a service account with the least permissions necessary.


[Learn more about creating and using
encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
ssh-known-hosts:
Expand All @@ -37,6 +45,10 @@ inputs:
and `CheckHostIP=no` to the SSH command line. Use the input `ssh-known-hosts` to
configure additional hosts.
default: true
ssh-user:
description: >
The user to use when connecting to the remote SSH host. By default 'git' is used.
default: git
persist-credentials:
description: 'Whether to configure the token or SSH key with the local git config'
default: true
Expand All @@ -45,27 +57,102 @@ inputs:
clean:
description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching'
default: true
filter:
description: >
Partially clone against a given filter.
Overrides sparse-checkout if set.
default: null
sparse-checkout:
description: >
Do a sparse checkout on given patterns.
Each pattern should be separated with new lines.
default: null
sparse-checkout-cone-mode:
description: >
Specifies whether to use cone-mode when doing a sparse checkout.
default: true
fetch-depth:
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
default: 1
fetch-tags:
description: 'Whether to fetch tags, even if fetch-depth > 0.'
default: false
show-progress:
description: 'Whether to show progress status output when fetching.'
default: true
lfs:
description: 'Whether to download Git-LFS files'
default: false
submodules:
description: >
Whether to checkout submodules: `true` to checkout submodules or `recursive` to
recursively checkout submodules.


When the `ssh-key` input is not provided, SSH URLs beginning with `[email protected]:` are
converted to HTTPS.
default: false
set-safe-directory:
description: Add repository path as safe.directory for Git global config by running `git config --global --add safe.directory <path>`
default: true
github-server-url:
description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://github.com or https://my-ghes-server.example.com
required: false
runs:
using: composite
steps:
- uses: _____checkout_____@_____SHA_____
id: local
with:
${{ insert }}: ${{ inputs }}
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
token: ${{ inputs.token }}
ssh-key: ${{ inputs.ssh-key }}
ssh-known-hosts: ${{ inputs.ssh-known-hosts }}
ssh-strict: ${{ inputs.ssh-strict }}
ssh-user: ${{ inputs.ssh-user }}
persist-credentials: ${{ inputs.persist-credentials }}
path: ${{ inputs.path }}
clean: ${{ inputs.clean }}
filter: ${{ inputs.filter }}
sparse-checkout: ${{ inputs.sparse-checkout }}
sparse-checkout-cone-mode: ${{ inputs.sparse-checkout-cone-mode }}
fetch-depth: ${{ inputs.fetch-depth }}
fetch-tags: ${{ inputs.fetch-tags }}
show-progress: ${{ inputs.show-progress }}
lfs: ${{ inputs.lfs }}
submodules: ${{ inputs.submodules }}
set-safe-directory: ${{ inputs.set-safe-directory }}
github-server-url: ${{ inputs.github-server-url }}
checkoutref: _____REF_____
- uses: _____checkout_____@_____SHA__________REF_____
if: "!fromJSON(steps.local.outputs.skip)"
with: ${{ inputs }}
id: remote
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
token: ${{ inputs.token }}
ssh-key: ${{ inputs.ssh-key }}
ssh-known-hosts: ${{ inputs.ssh-known-hosts }}
ssh-strict: ${{ inputs.ssh-strict }}
ssh-user: ${{ inputs.ssh-user }}
persist-credentials: ${{ inputs.persist-credentials }}
path: ${{ inputs.path }}
clean: ${{ inputs.clean }}
filter: ${{ inputs.filter }}
sparse-checkout: ${{ inputs.sparse-checkout }}
sparse-checkout-cone-mode: ${{ inputs.sparse-checkout-cone-mode }}
fetch-depth: ${{ inputs.fetch-depth }}
fetch-tags: ${{ inputs.fetch-tags }}
show-progress: ${{ inputs.show-progress }}
lfs: ${{ inputs.lfs }}
submodules: ${{ inputs.submodules }}
set-safe-directory: ${{ inputs.set-safe-directory }}
github-server-url: ${{ inputs.github-server-url }}
outputs:
ref:
description: 'The branch, tag or SHA that was checked out'
value: ${{ steps.remote.outputs.ref }}
commit:
description: 'The commit SHA that was checked out'
value: ${{ steps.remote.outputs.commit }}
Loading