Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elementor Pro example #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/examples/elementor-pro.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]

- 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/[email protected]
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