Updated default branch to main.8.x #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build Release | |
on: | |
pull_request: | |
types: [closed] | |
branches: [main.8.x] | |
workflow_dispatch: | |
inputs: | |
BASELINE: | |
description: 'Release branch' | |
required: true | |
default: 'main.8.x' | |
env: | |
NPM_REGISTRY: https://registry.npmjs.org/ | |
CI_EMAIL: ontimize-web@imatia.com | |
CI_USERNAME: ontimize-web | |
DEVELOP_BRANCH: 8.x.x | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')) | |
steps: | |
- name: Get input parameters | |
run: | | |
echo "BASELINE_BRANCH=${{ github.event.inputs.BASELINE || github.ref }}" >> $GITHUB_ENV | |
- name: Checkout merge commit | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.BASELINE_BRANCH }} | |
fetch-depth: 0 | |
- name: 'Cache node modules' | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Node 12.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 12.13.0 | |
registry-url: ${{ env.NPM_REGISTRY }} | |
- name: obtain package.json version | |
id: project | |
run: | | |
echo "version=$(node -pe "require('./package.json')['version']")" >> $GITHUB_OUTPUT | |
- name: abort if SNAPSHOT | |
if: "contains(steps.project.outputs.version, 'SNAPSHOT')" | |
run: | | |
echo "Version ${{ steps.project.outputs.version }} is not a properly named for RELEASE" | |
exit 1 | |
- name: npm install and npm run build | |
run: | | |
npm i | |
npm run production-aot-server | |
mkdir -p dist/ftp && tar -cvf dist/ftp/dist.tar dist/* | |
- name: backup previous deploy | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: cd /home/systems/ftp-demos && ls -l -a && ./backup-project playground8 | |
host: ${{ secrets.OWEB_CLOUD_DEMOS_HOST }} | |
port: ${{ secrets.OWEB_CLOUD_DEMOS_PORT }} | |
username: ${{ secrets.OWEB_CLOUD_DEMOS_USERNAME }} | |
password: ${{ secrets.OWEB_CLOUD_DEMOS_PASSWORD }} | |
env: | |
CI: true | |
- name: 📂 Sync files | |
uses: wangyucode/sftp-upload-action@v2.0.2 | |
with: | |
host: ${{ secrets.OWEB_CLOUD_DEMOS_HOST }} | |
port: ${{ secrets.OWEB_CLOUD_DEMOS_PORT }} | |
username: ${{ secrets.OWEB_CLOUD_DEMOS_USERNAME }} | |
password: ${{ secrets.OWEB_CLOUD_DEMOS_PASSWORD }} | |
localDir: dist/ftp/ | |
remoteDir: /home/systems/ftp-demos/playground8/ | |
- name: deploy pm2 | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: cd /home/systems/ftp-demos && ls -l -a && echo ${{ secrets.OWEB_CLOUD_DEMOS_PASSWORD }} | sudo -S ./deploy-project playground8 | |
host: ${{ secrets.OWEB_CLOUD_DEMOS_HOST }} | |
port: ${{ secrets.OWEB_CLOUD_DEMOS_PORT }} | |
username: ${{ secrets.OWEB_CLOUD_DEMOS_USERNAME }} | |
password: ${{ secrets.OWEB_CLOUD_DEMOS_PASSWORD }} | |
env: | |
CI: true | |
- name: GitHub Release / Create release | |
uses: ncipollo/release-action@2792aea87063cfd0d27953ac38e3ab45afacc154 | |
with: | |
commit: ${{ env.BASELINE_BRANCH }} | |
tag: ${{ steps.project.outputs.version }} | |
name: ${{ steps.project.outputs.version }} | |
token: ${{ secrets.OWEB_GH_TOKEN_PUSH }} | |
body: | | |
Released version ${{ steps.project.outputs.version }} of Playground | |
- name: Prepare git information | |
run: | | |
git config user.name "$CI_USERNAME" | |
git config user.email "$CI_EMAIL" | |
- name: bumping version in package.json | |
run: | | |
npm version $(npm version minor --no-git-tag-version)-SNAPSHOT-0 --no-git-tag-version | |
- name: Create sync branch | |
run: | | |
version=${{ steps.project.outputs.version }} | |
git checkout -b sync/release-$version-to-develop | |
git add . | |
git commit --allow-empty -m "Prepare next development iteration" | |
git push origin sync/release-$version-to-develop | |
- name: Create pull request | |
env: | |
GITHUB_TOKEN: ${{ secrets.OWEB_GH_TOKEN_PUSH }} | |
run: | | |
version=${{ steps.project.outputs.version }} | |
MESSAGE=" | |
Automated pull request for synchronizing released version ($version) into develop branch | |
### 💡 Merge Strategy: Create a merge commit | |
" | |
gh pr create -B ${{ env.DEVELOP_BRANCH }} -H sync/release-$version-to-develop --title "Sync release $version to develop" --body "$(echo -e "$MESSAGE")" |