├── .github └── workflows │ └── twitter-post.yml ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml └── entrypoint.sh /.github/workflows/twitter-post.yml: -------------------------------------------------------------------------------- 1 | name: Twitter Post On Release 2 | 3 | env: 4 | VS_WORKFLOW_TYPE: "twitter-post" 5 | 6 | on: 7 | release: 8 | types: 9 | - published 10 | 11 | jobs: 12 | twitter_post: 13 | name: "🐦 Tweet" 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: "📥 Fetching Repository Contents" 17 | uses: actions/checkout@main 18 | 19 | - name: "💾 Github Repository Metadata" 20 | uses: varunsridharan/action-repository-meta@main 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | 24 | - name: "💫 VS Utility" 25 | uses: varunsridharan/action-vs-utility@main 26 | env: 27 | SVA_ONL_TOKEN: ${{ secrets.SVA_ONL_TOKEN }} 28 | 29 | - name: "⚡ Repository - Before Hook" 30 | run: | 31 | echo " " 32 | if [ -f $VS_BEFORE_HOOK_FILE_LOCATION ]; then 33 | echo "✅ Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION" 34 | sh $VS_BEFORE_HOOK_FILE_LOCATION 35 | else 36 | echo "⚠️ No Before Hook File Found : $VS_BEFORE_HOOK_FILE_LOCATION" 37 | fi 38 | echo " " 39 | 40 | - name: "🚀 Publishing Tweet 🐦 " 41 | uses: m1ner79/Github-Twittction@master 42 | with: 43 | twitter_status: ${{ env.TWITTER_STATUS }} 44 | twitter_consumer_key: ${{ secrets.TWITTER_API_KEY }} 45 | twitter_consumer_secret: ${{ secrets.TWITTER_API_SECRET_KEY }} 46 | twitter_access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN }} 47 | twitter_access_token_secret: ${{ secrets.TWITTER_ACCESS_SECRET_TOKEN }} 48 | 49 | - name: "⚡ Repository - After Hook" 50 | run: | 51 | echo " " 52 | if [ -f $VS_AFTER_HOOK_FILE_LOCATION ]; then 53 | echo "✅ After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION" 54 | sh $VS_AFTER_HOOK_FILE_LOCATION 55 | else 56 | echo "⚠️ No After Hook File Found : $VS_AFTER_HOOK_FILE_LOCATION" 57 | fi 58 | echo " " -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stable-slim 2 | 3 | RUN apt-get update && apt-get install -y subversion rsync git zip && apt-get clean -y && rm -rf /var/lib/apt/lists/* 4 | 5 | COPY entrypoint.sh /entrypoint.sh 6 | 7 | RUN chmod 777 entrypoint.sh 8 | 9 | ENTRYPOINT ["/entrypoint.sh"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Varun Sridharan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordPress.org Plugin Deploy - ***Github Action*** 2 | This Action commits the contents of your Git tag to the WordPress.org plugin repository using the same tag name. 3 | It excludes Git-specific items or files and directories as optionally defined in your `.wporgignore` file, and 4 | moves anything from a `.wordpress-org` subdirectory to the top-level `assets` directory in Subversion (plugin banners, icons, and screenshots). 5 | 6 | ## Configuration 7 | ### Required secrets 8 | * `WORDPRESS_USERNAME` 9 | * `WORDPRESS_PASSWORD` 10 | * `GITHUB_TOKEN` - you do not need to generate one but you do have to explicitly make it available to the Action 11 | 12 | Secrets can be set while editing your workflow or in the repository settings. They cannot be viewed once stored. [GitHub secrets documentation](https://developer.github.com/actions/creating-workflows/storing-secrets/) 13 | 14 | ### Optional environment variables 15 | * `SLUG` - defaults to the respository name, customizable in case your WordPress repository has a different slug. This should be a very rare case as WordPress assumes that the directory and initial plugin file have the same slug. 16 | * `VERSION` - defaults to the tag name; do not recommend setting this except for testing purposes 17 | * `ASSETS_DIR` - defaults to `.wordpress-org`, customizable for other locations of WordPress.org plugin repository-specific assets that belong in the top-level `assets` directory (the one on the same level as `trunk`) 18 | * `IGNORE_FILE` - defaults to `.wporgignore`, customizable for other locations of list of files to be ignore like `.gitignore` 19 | * `ASSETS_IGNORE_FILE` - defaults to `.wporgassetsignore`, customizable for other locations of list of files to be ignore like `.gitignore` 20 | * `DIST_LOCATION` - defaults to `./dist/`, option to save final zip files. 21 | 22 | ### Excluding files from deployment 23 | If there are files or directories to be excluded from deployment, such as tests or editor config files, they can be specified in your `.wporgignore` file. If you use this method, please be sure to include the following items: 24 | 25 | ```gitignore 26 | # Directories 27 | .wordpress-org 28 | .github 29 | 30 | # Files 31 | /.gitattributes 32 | /.gitignore 33 | ``` 34 | 35 | > **⚠️ Note:** You Should Provide Github Token. If Not No Updated File Will Be Committed & Pushed 36 | 37 | ## Example Workflow File 38 | ```yaml 39 | name: Deploy to WordPress.org 40 | on: 41 | push: 42 | branches: 43 | - refs/tags/* 44 | jobs: 45 | tag: 46 | name: New tag 47 | runs-on: ubuntu-latest 48 | steps: 49 | - uses: actions/checkout@master 50 | - name: WordPress Plugin Deploy 51 | uses: varunsridharan/action-wp-org-deploy@master 52 | with: 53 | WORDPRESS_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }} 54 | WORDPRESS_USERNAME: ${{ secrets.WORDPRESS_USERNAME }} 55 | SLUG: my-super-cool-plugin 56 | env: 57 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 58 | ``` 59 | 60 | ## Credits 61 | This Github Action Bootstrapped From 62 | * [10up/action-wordpress-plugin-deploy](https://github.com/10up/action-wordpress-plugin-deploy) 63 | * [rtCamp/action-wordpress-org-plugin-deploy](https://github.com/10up/rtCamp/action-wordpress-org-plugin-deploy) 64 | 65 | --- 66 | ## Change Log 67 | 68 | ### 1.3 - 29/04/2020 69 | * Added Custom Arg To Provide Path To Save Dist File. 70 | 71 | ### 1.2 - 29/04/2020 72 | * Improved Logging 73 | 74 | ### 1.1 - 06/09/2019 75 | * Added Option To Exclude Files When Updating Assets Folder. 76 | 77 | ### 1.0 - 24/08/2019 78 | * First Release 79 | 80 | ## Contribute 81 | If you would like to help, please take a look at the list of 82 | [issues][issues] or the [To Do](#-todo) checklist. 83 | 84 | ## License 85 | Our GitHub Actions are available for use and remix under the MIT license. 86 | 87 | ## Copyright 88 | 2017 - 2018 Varun Sridharan, [varunsridharan.in][website] 89 | 90 | If you find it useful, let me know :wink: 91 | 92 | You can contact me on [Twitter][twitter] or through my [email][email]. 93 | 94 | ## Backed By 95 | | [![DigitalOcean][do-image]][do-ref] | [![JetBrains][jb-image]][jb-ref] | [![Tidio Chat][tidio-image]][tidio-ref] | 96 | | --- | --- | --- | 97 | 98 | [twitter]: https://twitter.com/varunsridharan2 99 | [email]: mailto:varunsridharan23@gmail.com 100 | [website]: https://varunsridharan.in 101 | [issues]: issues/ 102 | 103 | [do-image]: https://vsp.ams3.cdn.digitaloceanspaces.com/cdn/DO_Logo_Horizontal_Blue-small.png 104 | [jb-image]: https://vsp.ams3.cdn.digitaloceanspaces.com/cdn/phpstorm-small.png?v3 105 | [tidio-image]: https://vsp.ams3.cdn.digitaloceanspaces.com/cdn/tidiochat-small.png 106 | [do-ref]: https://s.svarun.in/Ef 107 | [jb-ref]: https://www.jetbrains.com 108 | [tidio-ref]: https://tidiochat.com 109 | 110 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'WordPress Org Deploy' 2 | description: 'Github Action Pushes WordPress.org Plugins Update' 3 | author: 'varunsridharan' 4 | branding: 5 | icon: 'upload-cloud' 6 | color: 'blue' 7 | inputs: 8 | WORDPRESS_USERNAME: 9 | description: 'WordPress.org Username' 10 | default: '' 11 | WORDPRESS_PASSWORD: 12 | description: 'WordPress.org PASSWORD' 13 | default: '' 14 | SLUG: 15 | description: 'Plugin Slug' 16 | default: '' 17 | VERSION: 18 | description: 'Plugin Version' 19 | default: '' 20 | ASSETS_DIR: 21 | description: 'Plugin Assets Dir For WordPress.org' 22 | default: '.wordpress-org' 23 | IGNORE_FILE: 24 | description: 'WordPress.org Exclude List File' 25 | default: '.wporgignore' 26 | ASSETS_IGNORE_FILE: 27 | description: 'WordPress.org Assets Exclude List File' 28 | default: '.wporgassetsignore' 29 | DIST_LOCATION: 30 | description: 'Provide a path here final zip file can be stored. which can be used by other actions.' 31 | default: 'dist/' 32 | 33 | 34 | runs: 35 | using: 'docker' 36 | image: 'Dockerfile' 37 | args: 38 | - ${{ inputs.WORDPRESS_USERNAME }} 39 | - ${{ inputs.WORDPRESS_PASSWORD }} 40 | - ${{ inputs.SLUG }} 41 | - ${{ inputs.VERSION }} 42 | - ${{ inputs.ASSETS_DIR }} 43 | - ${{ inputs.IGNORE_FILE }} 44 | - ${{ inputs.ASSETS_IGNORE_FILE }} 45 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eo 4 | 5 | WORDPRESS_USERNAME="$INPUT_WORDPRESS_USERNAME" 6 | WORDPRESS_PASSWORD="$INPUT_WORDPRESS_PASSWORD" 7 | SLUG="$INPUT_SLUG" 8 | VERSION="$INPUT_VERSION" 9 | ASSETS_DIR="$INPUT_ASSETS_DIR" 10 | IGNORE_FILE="$INPUT_IGNORE_FILE" 11 | ASSETS_IGNORE_FILE="$INPUT_ASSETS_IGNORE_FILE" 12 | 13 | # Ensure SVN username and password are set 14 | # IMPORTANT: secrets are accessible by anyone with write access to the repository! 15 | if [[ -z "$WORDPRESS_USERNAME" ]]; then 16 | echo "🔴 Set the WORDPRESS_USERNAME secret" 17 | exit 1 18 | fi 19 | 20 | if [[ -z "$WORDPRESS_PASSWORD" ]]; then 21 | echo "🔴 Set the WORDPRESS_PASSWORD secret" 22 | exit 1 23 | fi 24 | 25 | # Allow some ENV variables to be customized 26 | if [[ -z "$SLUG" ]]; then 27 | SLUG=${GITHUB_REPOSITORY#*/} 28 | fi 29 | 30 | # Does it even make sense for VERSION to be editable in a workflow definition? 31 | if [[ -z "$VERSION" ]]; then 32 | VERSION=${GITHUB_REF#refs/tags/} 33 | fi 34 | 35 | if [[ -z "$ASSETS_DIR" ]]; then 36 | ASSETS_DIR=".wordpress-org" 37 | fi 38 | 39 | if [[ -z "$IGNORE_FILE" ]]; then 40 | IGNORE_FILE=".wporgignore" 41 | fi 42 | 43 | if [[ -z "$ASSETS_IGNORE_FILE" ]]; then 44 | ASSETS_IGNORE_FILE=".wporgassetsignore" 45 | fi 46 | 47 | if [[ -z "$DIST_LOCATION" ]]; then 48 | DIST_LOCATION="dist/" 49 | fi 50 | 51 | echo " " 52 | echo '##[group] ➤ Workflow Arguments' 53 | # Echo Plugin Slug 54 | echo "ℹ︎ WordPress Plugin SLUG is $SLUG" 55 | # Echo Plugin Version 56 | echo "ℹ︎ VERSION is $VERSION" 57 | # Echo Assets DIR 58 | echo "ℹ︎ ASSETS_DIR is $ASSETS_DIR" 59 | echo '##[endgroup]' 60 | 61 | SVN_URL="http://plugins.svn.wordpress.org/${SLUG}/" 62 | SVN_DIR="/github/svn-${SLUG}" 63 | 64 | # Checkout just trunk and assets for efficiency 65 | # Tagging will be handled on the SVN level 66 | echo "##[group] ➤ Checking out .org repository..." 67 | svn checkout --depth immediates "$SVN_URL" "$SVN_DIR" 68 | cd "$SVN_DIR" 69 | svn update --set-depth infinity assets 70 | svn update --set-depth infinity trunk 71 | echo "##[endgroup]" 72 | 73 | echo "##[group] ➤ Copying files..." 74 | cd "$GITHUB_WORKSPACE" 75 | # "Export" a cleaned copy to a temp directory 76 | TMP_DIR="/github/archivetmp" 77 | ASSET_TMP_DIR="/github/assettmp" 78 | mkdir "$TMP_DIR" 79 | mkdir "$ASSET_TMP_DIR" 80 | echo ".git .github .gitignore .gitattributes ${ASSETS_DIR} ${IGNORE_FILE} ${ASSETS_IGNORE_FILE} node_modules" | tr " " "\n" >>"$GITHUB_WORKSPACE/$IGNORE_FILE" 81 | echo "*.psd .DS_Store Thumbs.db ehthumbs.db ehthumbs_vista.db .git .github .gitignore .gitattributes ${ASSETS_DIR} ${IGNORE_FILE} ${ASSETS_IGNORE_FILE} node_modules" | tr " " "\n" >>"$GITHUB_WORKSPACE/$ASSETS_IGNORE_FILE" 82 | echo "##[endgroup]" 83 | 84 | # This will exclude everything in the $IGNORE_FILE file 85 | echo "##[group] ➤ Removing Exlucded Files From Plugin Source" 86 | rsync -r --delete --exclude-from="$GITHUB_WORKSPACE/$IGNORE_FILE" "./" "$TMP_DIR" 87 | echo "##[endgroup]" 88 | # This will exclude everything in the $ASSETS_IGNORE_FILE file 89 | cd "$ASSETS_DIR" 90 | echo "##[group] ➤ Removing Exlucded Files From Assets Folder" 91 | rsync -r --delete --exclude-from="$GITHUB_WORKSPACE/$ASSETS_IGNORE_FILE" "./" "$ASSET_TMP_DIR" 92 | 93 | cd "$SVN_DIR" 94 | 95 | # Copy from clean copy to /trunk, excluding dotorg assets 96 | # The --delete flag will delete anything in destination that no longer exists in source 97 | rsync -rc "$TMP_DIR/" trunk/ --delete 98 | # Copy dotorg assets to /assets 99 | rsync -rc "$ASSET_TMP_DIR/" assets/ --delete 100 | echo "##[endgroup]" 101 | 102 | # Add everything and commit to SVN 103 | # The force flag ensures we recurse into subdirectories even if they are already added 104 | # Suppress stdout in favor of svn status later for readability 105 | echo "##[group] ➤ Preparing files..." 106 | svn add . --force >/dev/null 107 | 108 | # SVN delete all deleted files 109 | # Also suppress stdout here 110 | svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % >/dev/null 111 | echo "##[endgroup]" 112 | 113 | # Copy tag locally to make this a single commit 114 | echo "##[group] ➤ Copying tag..." 115 | svn cp "trunk" "tags/$VERSION" 116 | echo "##[endgroup]" 117 | 118 | echo "##[group] SVN Status" 119 | svn status 120 | echo "##[endgroup]" 121 | 122 | echo "##[group] ➤ Committing files..." 123 | svn commit -m "Update to version $VERSION from GitHub" --no-auth-cache --non-interactive --username "$WORDPRESS_USERNAME" --password "$WORDPRESS_PASSWORD" 124 | echo "##[endgroup] 125 | ✓ Plugin deployed!" 126 | 127 | echo "##[group] Creating Dist File" 128 | mkdir "$GITHUB_WORKSPACE/$DIST_LOCATION" 129 | zip -r9 "$GITHUB_WORKSPACE/$DIST_LOCATION/$SLUG-$VERSION.zip" "tags/$VERSION/" 130 | zip -r9 "$GITHUB_WORKSPACE/$DIST_LOCATION/$SLUG-$VERSION-assets.zip" "assets/" 131 | echo "##[endgroup]" 132 | --------------------------------------------------------------------------------