-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fathym setup and configured GitHub action
- Loading branch information
1 parent
7cbdbc7
commit 69fcf4a
Showing
1 changed file
with
118 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
name: HamzaZaidiX/Portfolio-App-By-React-Bricks | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
permissions: write-all | ||
|
||
env: | ||
CI: false | ||
Branches: main | ||
MainBranch: main | ||
NPMRegistry: https://registry.npmjs.org/ | ||
InstallCommand: npm i | ||
BuildCommand: npm run build | ||
Output: ./ | ||
|
||
jobs: | ||
build: | ||
# Build And Publish | ||
name: Build and Publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
# checkout repository | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' | ||
|
||
# set variables | ||
- name: Set variables | ||
id: vars | ||
run: | | ||
branch=${GITHUB_REF##*/} | ||
echo ::set-output name=branchName::$branch | ||
if [ "$branch" == "${{ env.MainBranch }}" ] | ||
then | ||
echo "::set-output name=versionBump::minor" | ||
else | ||
echo "::set-output name=versionBump::patch" | ||
fi | ||
- run: | | ||
echo "Set Variable Checks ${{ github.ref }}" | ||
echo "Current branch is ${{ steps.vars.outputs.branchName }}" | ||
echo "Version bump type is ${{ steps.vars.outputs.versionBump }}" | ||
# Check package.json exists | ||
- name: Check package.json existence | ||
id: package_json_exists | ||
uses: fathym/file-existence-action@master | ||
with: | ||
files: "package.json" | ||
|
||
# replace text in package.json for main branch | ||
- name: replace version text for main branch | ||
if: ${{ steps.vars.outputs.branchName == env.MainBranch && steps.package_json_exists.outputs.files_exists == 'true' }} | ||
shell: pwsh | ||
run: (Get-Content -path package.json -Raw) -replace "version patch","version ${{ steps.versionBump.outputs.new_tag }} --no-git-tag-version -f" | Set-Content -Path package.json | ||
|
||
# replace text in package.json for dev branches | ||
- name: replace tag text for dev branches | ||
if: ${{ steps.vars.outputs.branchName != env.MainBranch && steps.package_json_exists.outputs.files_exists == 'true' }} | ||
shell: pwsh | ||
run: (Get-Content -path package.json -Raw) -replace "--access public","--access public --tag ${{ steps.vars.outputs.branchName }}" | Set-Content -Path package.json | ||
|
||
- name: replace version text for dev branches | ||
if: ${{ steps.vars.outputs.branchName != env.MainBranch && steps.package_json_exists.outputs.files_exists == 'true' }} | ||
shell: pwsh | ||
run: (Get-Content -path package.json -Raw) -replace "version patch","version ${{ steps.versionBump.outputs.new_tag }}-${{ steps.vars.outputs.branchName }} --no-git-tag-version -f" | Set-Content -Path package.json | ||
|
||
# run npm commands | ||
- uses: actions/setup-node@v2 | ||
if: ${{ (!!env.InstallCommand || !!env.BuildCommand) && steps.package_json_exists.outputs.files_exists == 'true' }} | ||
with: | ||
node-version: 14 | ||
registry-url: ${{ env.NPMRegistry }} | ||
|
||
# install npm dependencies from package-lock.json | ||
- name: npm install | ||
if: ${{ !!env.InstallCommand && steps.package_json_exists.outputs.files_exists == 'true' }} | ||
run: ${{ env.InstallCommand }} | ||
|
||
# build npm | ||
- name: npm build | ||
if: ${{ !!env.BuildCommand && steps.package_json_exists.outputs.files_exists == 'true' }} | ||
run: ${{ env.BuildCommand }} | ||
|
||
# publish github artifacts | ||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ github.event.organization.name }}-${{ github.event.repository.name }} | ||
path: ${{ env.Output }} | ||
|
||
# bump version and push tag | ||
- name: Bump version and push tag | ||
id: versionBump | ||
uses: fathym/github-tag-action@master | ||
if: ${{ steps.package_json_exists.outputs.files_exists == 'true' }} | ||
env: | ||
DEFAULT_BUMP: ${{ steps.vars.outputs.versionBump }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
RELEASE_BRANCHES: .* | ||
WITH_V: false | ||
- run: echo "New version is ${{ steps.versionBump.outputs.new_tag }}" | ||
|
||
# webhook to LowCodeUnit | ||
- name: Invoke deployment hook | ||
uses: fathym/workflow-webhook@v2 | ||
env: | ||
webhook_url: ${{ secrets.LCU_WEBHOOK_URL }} | ||
webhook_secret: ${{ secrets.LCU_WEBHOOK_SECRET }} | ||
data: '{ "EnterpriseLookup": "${{ secrets.LCU_ENTERPRISE_LOOKUP }}", "Username": "${{ secrets.LCU_USERNAME }}" }' |
69fcf4a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
hamza-zaidi-portfolio – ./
hamza-zaidi-portfolio-git-main-shjz.vercel.app
hamza-zaidi-portfolio.vercel.app
hamza-zaidi-portfolio-shjz.vercel.app