Skip to content

Instantly share code, notes, and snippets.

@Xilonz
Last active April 4, 2020 17:01
Show Gist options
  • Save Xilonz/77b2938d54e118307b1c68bb59078192 to your computer and use it in GitHub Desktop.
Save Xilonz/77b2938d54e118307b1c68bb59078192 to your computer and use it in GitHub Desktop.
Sync-back WordPress plugin from Satis
name: Update Plugin
on:
pull_request
jobs:
sync_plugin:
name: Sync-back plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: current dir to workpace
run: cd $GITHUB_WORKSPACE
- name: Setup Composer Authentication
run: composer config http-basic.satis.steenbergen.cloud ${{ secrets.SatispressToken }} satispress
- name: Install packages
run: composer install
- name: Get Plugin Version
id: plugin_info
run: echo "::set-output name=version::$(composer show 'satispress/plugin' | grep 'versions' | grep -o -E '\*\ .+' | cut -d' ' -f2 | cut -d',' -f1 )"
- name: Move Plugin to tmp
run: |
echo "::debug::$( ls tmp/plugin -la )"
shopt -s dotglob
if [ -d "tmp/plugin/plugin" ]; then
echo "::debug::They still didn't fix their package..."
mkdir --parents ~/tmp/plugin; mv tmp/plugin/plugin/* $_
else
echo "::debug::Wohoo! They fixed their package!"
mkdir --parents ~/tmp/plugin; mv tmp/plugin/* $_
fi
shopt -u dotglob
- name: Checkout to new empty branch and clean folder
run: |
git checkout --orphan ${{ steps.plugin_info.outputs.version }}-branch
git reset --hard
rm -rf *
echo "::debug::$( ls -la )"
- name: Move Plugin back to workspace root
run: |
echo "::debug::$( ls ~/tmp/plugin -la )"
shopt -s dotglob
mv -f ~/tmp/plugin/* $GITHUB_WORKSPACE
shopt -u dotglob
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Plugin version ${{ steps.plugin_info.outputs.version }}" -a
- name: Tag new release
run: git tag -a ${{ steps.plugin_info.outputs.version }} -m "Plugin version ${{ steps.plugin_info.outputs.version }}"
- name: Push changes
run: git push -u origin ${{ steps.plugin_info.outputs.version }}-branch --tags
- name: Zip files
run: |
zip -r plugin.zip . --exclude *.git*
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.plugin_info.outputs.version }}
release_name: Plugin version ${{ steps.plugin_info.outputs.version }}
body: |
Plugin version ${{ steps.plugin_info.outputs.version }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./plugin.zip
asset_name: plugin.zip
asset_content_type: application/zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment