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

Update entrypoint to allow usage with actions/checkout #16

Conversation

weierophinney
Copy link
Member

@weierophinney weierophinney commented Mar 5, 2021

The "checkout" function in the entrypoint was not flexible enough:

  • it required that we operate within a github event (when running locally, we may not want that)
  • it would fail if actions/checkout had occurred prior to running it, or if mapping a WORKDIR that contained a checkout (e.g., when running locally)

This patch modifies it such that:

  • If no GITHUB_EVENT_NAME, GITHUB_REPOSITORY, or GITHUB_REF env variables are present, it performs a no-op (assumption is running the container locally and mapping the WORKDIR)
  • If a .git directory exsts, it will:
    • remove the "origin" remote if it is already defined
    • add an "origin" remote pointing to the canonical repository
    • fetch the origin
  • Otherwise it clones the canonical repository in the working directory

(This is the same logic used in the laminas-continous-integration-action entrypoint.)

Fixes #15

The "checkout" function in the entrypoint was not flexible enough:

- it required that we operate within a github event (when running locally, we may not want that)
- it would fail if actions/checkout had occurred prior to running it, or if mapping a WORKDIR that contained a checkout (e.g., when running locally)

This patch modifies it such that:

- If no GITHUB_EVENT_NAME, GITHUB_REPOSITORY, or GITHUB_REF env variables are present, it performs a no-op (assumption is running the container locally and mapping the WORKDIR)
- If a `.git` directory exsts, it will:
  - remove the "origin" remote if it is already defined
  - add an "origin" remote pointing to the canonical repository
  - fetch the origin
- Otherwise it clones the canonical repository in the working directory

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney added this to the 1.4.0 milestone Mar 5, 2021
Document that it's not required, and should only be used if you need to access artifacts in a later step.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney merged commit 9e113da into laminas:1.4.x Mar 5, 2021
@weierophinney weierophinney deleted the hotfix/allow-usage-with-actions-checkout branch March 5, 2021 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modify checkout routine in entrypoint to play nice with action/checkout
1 participant