Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Add an automated zip workflow#6862

Closed
pbking wants to merge 1 commit into
trunkfrom
add/automated-zip-workflow
Closed

Add an automated zip workflow#6862
pbking wants to merge 1 commit into
trunkfrom
add/automated-zip-workflow

Conversation

@pbking
Copy link
Copy Markdown
Contributor

@pbking pbking commented Feb 10, 2023

Changes proposed in this Pull Request:

This action will automatically open a PR when a .zip file is attached to an issue BODY or COMMENT.

(NOTE: I think that this will need to be MERGED before it will actually run which makes it kinda hard to test... You can see [many] test runs here to see what this change is supposed to accomplish).

This action allows for the following workflow:

  • A designer creates a theme locally (or on a demo site).
  • They export the theme as a .zip file (using Create Block Theme) i.e. banana.zip.
  • They open a New Issue in this repository. In the BODY of that issue they attach (just drag 'n drop) the theme .zip file that was exported.
  • This script will then create a new branch (based on the name of the .zip file i.e. auto/banana ).
    • If a branch of that name already exists then it will be checked out instead of created
  • The contents of that zip file will be extracted into a folder (also of the same name as the .zip file).
  • The new (or changed) files will be committed to that branch.
  • A Pull Request will be opened to merge these changes to the trunk branch and associated with the originally opened Issue (noted in step 3).
  • Anybody can then check out & review the changes; it's just a normal branch. Comments can be made on the PR (or issue).
  • To make changes to the PR the designer can simply repeat the steps; exporting the theme .zip file using Create Block Theme and either:
    • replacing the zip file on the issue
    • (recommended) adding a comment with a new zip file to the issue
  • Each time a zip file is added to the issue a new commit is made to the branch
  • Once the changes are approved the branch can be merged

This closes #6850

@pbking pbking requested a review from a team February 10, 2023 19:24
@jffng
Copy link
Copy Markdown
Contributor

jffng commented Feb 13, 2023

Very cool work and great POC, I think this definitely is a promising step in the right direction!

I tested this out and both adding a new theme and updating an existing one appears to be working well.

I ran into a couple issues when trying to post an update via a comment:

  • On my first comment, I made some changes to the theme in a text editor, zip'd it back up, uploaded. The result was that the theme appeared in a subfolder, as well as macOS's hidden files being added to the PR. I'm not totally sure what's going on there, but perhaps we could create some kind of ignore so that unwanted files don't get added.
  • In my second comment, the updates were applied correctly but it did not remove the unwanted files. Should the behavior instead be a full overwrite of the previous changes (more like how rsync works)?

More generally, I think there are a few issues we should solve before this PR will be useful:

WordPress/create-block-theme#174
WordPress/create-block-theme#213
WordPress/gutenberg#42730

Copy link
Copy Markdown
Contributor

@madhusudhand madhusudhand left a comment

Choose a reason for hiding this comment

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

Great work! It's a nice step to automate the theme launch process. 🎆

I tested this with few scenarios and left minor feedback inline.

with:
destination_branch: "trunk"
source_branch: "${{ env.BRANCH_NAME }}"
pr_title: "Automated Theme Change: [${{ env.THEME_NAME }}]"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For title, I think its good avoid automation keyword. I suggest something like Add new theme: THEME_NAME

Suggested change
pr_title: "Automated Theme Change: [${{ env.THEME_NAME }}]"
pr_title: "Add new theme: ${{ env.THEME_NAME }}"


Closes: #${{ github.event.issue.number }}

_ No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also add pr_reviewer (Theam) and pr_assignee (self) ?

echo "ZIP_URL=${{ steps.match-url.outputs.group1 }}" >> $GITHUB_ENV
echo "ZIP_FILENAME=${{ steps.match-filename.outputs.group1 }}" >> $GITHUB_ENV
echo "THEME_NAME=${{ steps.match-theme-name.outputs.group1 }}" >> $GITHUB_ENV
echo "BRANCH_NAME=auto/${{ steps.match-theme-name.outputs.group1 }}" >> $GITHUB_ENV
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

since the branch name is derived from the zip name,
when zip name changes on edit ex: theme-name to theme-name(1),
it creates a fresh branch and a new PR instead of updating existing one.

Also, it fails to create PR for zip name with spaces.

id: match-theme-name
with:
text: ${{ github.event.issue.body }}
regex: '\(.*\/(.*?)\.zip\)'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it will be nice to iterate later to bring THEME_NAME from style.css instead of zip name. (if there is no such name it can fallback to zip name)

id: match-url
with:
text: ${{ github.event.issue.body }}
regex: '\((.*?\.zip)\)'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The action triggers for any new issue created and creates PRs if it has a Zip attached.

Trigger the action on issues that are having a special label. like New Theme may be.

Comment on lines +55 to +77
- name: Extract Zip URL (comment)
uses: actions-ecosystem/action-regex-match@v2
if: ${{ github.event.comment.body }}
id: match-url-comment
with:
text: ${{ github.event.comment.body }}
regex: '\((.*?\.zip)\)'

- name: Extract Zip Filename (comment)
uses: actions-ecosystem/action-regex-match@v2
if: ${{ github.event.comment.body }}
id: match-filename-comment
with:
text: ${{ github.event.comment.body }}
regex: '\(.*\/(.*?\.zip)\)'

- name: Extract Theme Name (comment)
uses: actions-ecosystem/action-regex-match@v2
if: ${{ github.event.comment.body }}
id: match-theme-name-comment
with:
text: ${{ github.event.comment.body }}
regex: '\(.*\/(.*?)\.zip\)'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It triggers for any comment made on any issue. It should also be restricted only to issues that have special label.

@pbking
Copy link
Copy Markdown
Contributor Author

pbking commented Mar 17, 2023

I think that this is probably more moving parts than is helpful, coupled with a workflow that is cumbersome. Closing this idea now while pursuing git integration instead.

@pbking pbking closed this Mar 17, 2023
@pbking pbking deleted the add/automated-zip-workflow branch March 17, 2023 15:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automate the importing of a theme

3 participants