Skip to content

Conversation

@dinhtungdu
Copy link
Contributor

Description of the Change

This PR supports deploying plugin files from a custom build directory by introducing a new flag BUILD_DIR:

  • By default, $BUILD_DIR is set to false.
  • If an absolute path was given, $BUILD_DIR will keep using that path.
  • If a relative path was given, $BUILD_DIR will be concatenated with $GITHUB_WORKSPACE.

All files in the BUILD_DIR will be copied and deployed, and because those files are generated by a build command, there is no need to use .disignore or .gitattribute here.

Note: The asset files are still copied from the repository root directory.

Closes #16

Alternate Designs

#30 #56

Possible Drawbacks

Verification Process

This requires manual verification by deploying a real plugin using this branch.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Changelog Entry

Added - Custom build directory support.

Credits

Props @dinhtungdu @mauryaratan

@dinhtungdu dinhtungdu requested review from a team and cadic and removed request for a team February 11, 2022 09:35
@dinhtungdu dinhtungdu self-assigned this Feb 11, 2022
@dinhtungdu dinhtungdu added needs:code-review This requires code review. type:enhancement New feature or request. labels Feb 11, 2022
@dinhtungdu dinhtungdu added this to the 2.1.0 milestone Feb 11, 2022
cadic
cadic previously approved these changes Feb 11, 2022
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One change suggestion to clarify messaging but otherwise I only have a couple of questions.

Comment on lines +80 to +92
if [[ ! -e "$GITHUB_WORKSPACE/.gitattributes" ]]; then
cat > "$GITHUB_WORKSPACE/.gitattributes" <<-EOL
/$ASSETS_DIR export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
EOL

# Ensure we are in the $GITHUB_WORKSPACE directory, just in case
# The .gitattributes file has to be committed to be used
# Just don't push it to the origin repo :)
git add .gitattributes && git commit -m "Add .gitattributes file"
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth ignoring .gitignore and .gitattributes in the build directory. They can be placed anywhere in a repo.

I am undecided, can you tell me why you decided not to do so?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterwilsoncc I decided not to use .disignore or .gitattributes because I assume that if plugin authors use BUILD_DIR, they are using a command/script to build the plugin, so anything inside BUILD_DIR is meant to be deployed. They have control over any files copied to that folder. Using .disignore or .gitattributes here can cause confusions IMO.

# Copy from clean copy to /trunk, excluding dotorg assets
# The --delete flag will delete anything in destination that no longer exists in source
rsync -rc "$TMP_DIR/" trunk/ --delete --delete-excluded
if [[ "$BUILD_DIR" = false ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if BUILD_DIR = `` (empty string) or ./ (relative directory same as github repo's root directory?

What should happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 43e313a I cover more possible value of BUILD_DIR:

  • ./
  • ./some/directory

The empty string case is handled already by [[ -z "$BUILD_DIR" ]] which returns true if BUILD_DIR is unset or set to the empty string.

IMO, BUILD_DIR is set by users so ultimately, it's users' responsibility to set the correct value for it. We already cover common use-cases in this PR.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tung, this looks good to me.

I'm not sure how to test this so this is based on code review only, I haven't done any branch testing.

@jeffpaul jeffpaul merged commit 2a5e2c1 into develop Feb 15, 2022
@jeffpaul jeffpaul deleted the fix/custom-build-dir branch February 15, 2022 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review. type:enhancement New feature or request.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Deploy a specific directory within repository

4 participants