Skip to content

Commit

Permalink
fix: auto site deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Aug 20, 2023
1 parent 475dc8e commit b9c5a63
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
FORMBUILDER_WEBSITE_DIR: ${{ secrets.FORMBUILDER_WEBSITE_DIR }}
FORMBUILDER_WEBSITE_REPO: ${{ secrets.FORMBUILDER_WEBSITE_REPO }}

jobs:
build:
Expand Down Expand Up @@ -41,6 +39,24 @@ jobs:
if: success()
run: npx semantic-release

- name: Deploy the website
- name: Get npm package version using jq
if: success()
run: npm run deploy:site
id: get_version
run: |
VERSION=$(jq -r ".version" package.json)
echo "::set-output name=version::$VERSION"
- name: Deploy the website
env:
VERSION: ${{ steps.get_version.outputs.version }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git clone https://github.com/kevinchappell/formBuilder-site.git
cd formBuilder-site
npm version ${{ env.version }}
# Commit and push the changes
git commit -am "Update site to ${{ env.version }}"
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/kevinchappell/formBuilder-site.git master
6 changes: 1 addition & 5 deletions tools/deploy-site.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
const { exec } = require('child_process')
const pkg = require('../package.json')

const siteReo = pkg.repository.url.replace(/.git$/, '-site.git')
const siteDir = process.env.FORMBUILDER_WEBSITE_DIR || 'site'

const commands = [
`git clone ${siteReo} ${siteDir}`,
`cd ${siteDir}/`,
`cd ${process.env.FORMBUILDER_WEBSITE_DIR || 'site'}/`,
`npm version ${pkg.version}`,
'git push origin master',
]
Expand Down

0 comments on commit b9c5a63

Please sign in to comment.