Skip to content

Merge pull request #10 from PhilipDaas/main #79

Merge pull request #10 from PhilipDaas/main

Merge pull request #10 from PhilipDaas/main #79

Workflow file for this run

name: Deploy
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: rlespinasse/[email protected]
- shell: bash
run: |
PLUGIN_VERSION=$(node -pe 'JSON.parse(process.argv[1]).version' "$(curl -s https://obliosoftware.github.io/builds/woocommerce/info.json)")
PLUGIN_NEW_VERSION=$(node -pe 'let version=process.argv[1].match(/(\d{1,})\.(\d{1,})\.(\d{1,})/);version[1] + "." + version[2] + "." + (parseInt(version[3]) + 1)' $PLUGIN_VERSION)
echo "PLUGIN_NEW_VERSION=$PLUGIN_NEW_VERSION" >> $GITHUB_ENV
echo $PLUGIN_NEW_VERSION
sed -i "s/\[PLUGIN\_VERSION\]/$PLUGIN_NEW_VERSION/" woocommerce-oblio.php
mkdir -p deploy/woocommerce-oblio
ls | grep -v deploy | xargs mv -t deploy/woocommerce-oblio
mkdir -p packaging
ls -l
- name: Zip contents
if: ${{ success() }}
uses: vimtor/action-zip@v1
with:
files: deploy
dest: ./packaging/oblio-woocommerce.zip
- name: create-json
if: ${{ success() }}
shell: bash
run: |
COMMIT_MESSAGE='${{ github.event.head_commit.message }}'
NOW=$(date +'%Y-%m-%d %H:%M:%S')
JSON_TEMPLATE='{"version":"[PLUGIN_VERSION]",
"url":"https://www.oblio.eu/",
"download_url":"https://obliosoftware.github.io/builds/woocommerce/oblio-woocommerce.zip",
"requires":"6.3",
"tested":"6.4",
"requires_php":"7.4",
"last_updated":"[PLUGIN_LAST_UPDATE]",
"sections":{
"description":"Implementare API pentru oblio.eu",
"installation":"Please see <a href='https://codex.wordpress.org/Managing_Plugins#Installing_Plugins'>Installing Plugins</a> in the WordPress Codex.",
"changelog":"<h4>[PLUGIN_VERSION] - [PLUGIN_LAST_UPDATE]</h4><ul><li>[COMMIT_MESSAGE]</li></ul>"
},
"banners":{"1x":"https://www.oblio.eu/skins/images/favicons/oblio-icon-192x192.png"},
"icons":{
"1x":"https://www.oblio.eu/skins/images/favicons/oblio-icon-144x144.png",
"2x":"https://www.oblio.eu/skins/images/favicons/oblio-icon-192x192.png"
}}'
echo $JSON_TEMPLATE | PLUGIN_NEW_VERSION=$PLUGIN_NEW_VERSION \
COMMIT_MESSAGE=$COMMIT_MESSAGE \
PLUGIN_LAST_UPDATE=$NOW \
node -e "const fs = require('fs'); let jsonString = fs.readFileSync(0).toString('utf-8'); \
jsonString = jsonString.replaceAll('[PLUGIN_VERSION]', process.env.PLUGIN_NEW_VERSION); \
jsonString = jsonString.replaceAll('[COMMIT_MESSAGE]', process.env.COMMIT_MESSAGE.replaceAll(/(?:\r\n|\r|\n)/g, '<br>')); \
jsonString = jsonString.replaceAll('[PLUGIN_LAST_UPDATE]', process.env.PLUGIN_LAST_UPDATE); \
const json = JSON.parse(jsonString); console.log(JSON.stringify(json, null, ' '));" > ./packaging/info.json
- name: Pushes to builds repository
if: ${{ success() }}
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
with:
source-directory: './packaging'
target-directory: './woocommerce'
destination-github-username: '${{ env.GITHUB_REPOSITORY_OWNER_PART }}'
destination-repository-name: 'builds'
target-branch: main