From 810d3b5eae001c1d5e41286546f13036f1829d84 Mon Sep 17 00:00:00 2001 From: MWDelaney Date: Mon, 1 May 2023 13:43:56 -0400 Subject: [PATCH] Elementor Pro example --- .github/workflows/examples/elementor-pro.yml | 99 ++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .github/workflows/examples/elementor-pro.yml diff --git a/.github/workflows/examples/elementor-pro.yml b/.github/workflows/examples/elementor-pro.yml new file mode 100644 index 0000000..7be0e25 --- /dev/null +++ b/.github/workflows/examples/elementor-pro.yml @@ -0,0 +1,99 @@ +name: Elementor Pro Updater + +# Run this workflow twice daily +on: + schedule: + - cron: '0 */12 * * *' + workflow_dispatch: + +env: + PACKAGE_SLUG: "elementor-pro" + +jobs: + update: + name: Fetch and check versions + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # Use Elementor Pro API to find download link for latest + - name: Get download link from Elementor Pro API + id: ElementorAPIResponse + uses: fjogeleit/http-request-action@master + with: + url: 'https://my.elementor.com/api/v2/pro/info' + contentType: 'application/x-www-form-urlencoded' + method: 'POST' + data: '{"item_name": "${{ env.PACKAGE_SLUG }}", "license": "${{ secrets.ELEMENTOR_PRO_KEY }}", "url": "${{ secrets.ELEMENTOR_PRO_URL }}"}' + + # uncomment to debug or see other "offerings" your license can download + - name: Show Response + run: echo ${{ steps.ElementorAPIResponse.outputs.response }} + + # Fetch latest version of Elementor Pro to download + - name: Fetch + run: wget '${{ fromJson(steps.ElementorAPIResponse.outputs.response).download_link }}' -O package.zip + + # PHP + - name: 'Setup PHP' + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + + # Install dependencies + - name: Composer + run: 'composer install' + + # Get current tag + - name: 'Get Previous tag' + id: previous_version + uses: "WyriHaximus/github-action-get-previous-tag@v1" + + # Get new version + - name: 'Get version' + id: new_version + run: echo "new_version=$(php .github/workflows/check.php)" >> $GITHUB_OUTPUT + + - name: 'Git config' + if: ${{ steps.previous_version.outputs.tag != steps.new_version.outputs.new_version }} + run: | + git config user.name "GitHub Actions" + git config user.email noreply@github.com + + - name: 'Clean' + if: ${{ steps.previous_version.outputs.tag != steps.new_version.outputs.new_version }} + run: find . -maxdepth 1 \( -name 'package.zip' -o -name 'composer.json' -o -name 'composer.lock' -o -name '.gitignore' -o -path './.git' -o -path './.github' \) -prune -o -exec rm -rf {} \; + + - name: Unzip + if: ${{ steps.previous_version.outputs.tag != steps.new_version.outputs.new_version }} + uses: TonyBogdanov/zip@1.0 + with: + args: unzip -qq ./package.zip -d . + + # You may not need this step depending on the contents of the zip + - name: Move + if: ${{ steps.previous_version.outputs.tag != steps.new_version.outputs.new_version }} + run: shopt -s dotglob && sudo mv ${{ env.PACKAGE_SLUG }}/* . + + - name: rm + if: ${{ steps.previous_version.outputs.tag != steps.new_version.outputs.new_version }} + run: rm package.zip && rm -rf ${{ env.PACKAGE_SLUG }} + + - name: Commit + if: ${{ steps.previous_version.outputs.tag != steps.new_version.outputs.new_version }} + id: make-commit + run: | + git add . + git commit -m '${{ steps.new_version.outputs.new_version }}' + echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Push + if: ${{ steps.previous_version.outputs.tag != steps.new_version.outputs.new_version }} + run: | + git push + git tag ${{ steps.new_version.outputs.new_version }} + git push --tags