Deploy to Development by @dharmesh-hemaram #28
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: mono-repo [deploy] | |
run-name: Deploy to ${{ inputs.environment }} by @${{ github.actor }} | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment of release' | |
type: environment | |
default: Development | |
required: true | |
deploy_web: | |
description: 'Deploy web to azure static' | |
type: boolean | |
default: false | |
required: true | |
upload_extension: | |
description: 'Upload extension to chrome webstore' | |
type: boolean | |
default: false | |
required: true | |
publish_extension: | |
description: 'Publish extension' | |
type: boolean | |
default: false | |
required: true | |
publish_packages: | |
description: 'Publish packages' | |
type: boolean | |
default: false | |
required: true | |
release: | |
description: 'Release' | |
type: boolean | |
default: false | |
required: true | |
jobs: | |
main: | |
name: Build & Bundle | |
environment: | |
name: ${{inputs.environment}} | |
url: ${{ steps.artifact-upload-step.outputs.artifact-url }} | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
actions: read | |
id-token: write # needed for provenance data generation | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: https://npm.pkg.github.com | |
scope: ${{github.repository_owner}} | |
cache: 'npm' | |
- uses: nrwl/nx-set-shas@v3 | |
- run: | | |
echo "BASE: ${{ env.NX_BASE }}" | |
echo "HEAD: ${{ env.NX_HEAD }}" | |
- run: npm ci | |
- name: Build Projects and Library | |
run: npx nx run-many -t=build --parallel=3 --prod --base-href ${{vars.PUBLIC_URL}} | |
env: | |
NX_NAME: ${{vars.NX_NAME}} | |
NX_VARIANT: ${{vars.NX_VARIANT}} | |
NX_CHROME_EXTENSION_ID: ${{vars.NX_CHROME_EXTENSION_ID}} | |
NX_EDGE_EXTENSION_ID: ${{vars.NX_EDGE_EXTENSION_ID || 'DEV'}} | |
NX_I18N: ${{vars.NX_I18N}} | |
NX_GOOGLE_ANALYTICS_ID: ${{vars.NX_GOOGLE_ANALYTICS_ID}} | |
NX_GOOGLE_ADS_SLOT: ${{vars.NX_GOOGLE_ADS_SLOT}} | |
NX_GOOGLE_ADS_CLIENT: ${{vars.NX_GOOGLE_ADS_CLIENT}} | |
UNINSTALL_URL: ${{vars.UNINSTALL_URL}} | |
TRACKING_ID: ${{vars.TRACKING_ID}} | |
FUNCTION_URL: ${{vars.FUNCTION_URL}} | |
DISCORD_CLIENT_ID: ${{vars.DISCORD_CLIENT_ID}} | |
OAUTH_CLIENT_ID: ${{vars.OAUTH_CLIENT_ID}} | |
PUBLIC_URL: ${{vars.PUBLIC_URL}} | |
NX_RELEASE_VERSION: ${{github.ref_name}} | |
API_SECRET: ${{vars.API_SECRET}} | |
MEASUREMENT_ID: ${{vars.MEASUREMENT_ID}} | |
SENTRY_AUTH_TOKEN: ${{vars.SENTRY_AUTH_TOKEN}} | |
- name: Print Environment Info | |
run: npx nx report | |
- name: Publish Packages | |
if: ${{ inputs.publish_packages }} | |
run: npx nx release publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.REPO_PAT }} | |
- name: Bundle Projects | |
run: | | |
mkdir bundle | |
cd dist/apps | |
zip -r ../../bundle/acf-options-page.zip acf-options-page/ | |
zip -r ../../bundle/acf-i18n.zip acf-i18n/ | |
cd acf-extension | |
zip -r ../../../bundle/acf-extension.zip . | |
- uses: actions/upload-artifact@v4 | |
id: artifact-upload-step | |
with: | |
name: nx-main-artifacts | |
path: bundle/* | |
extension: | |
if: ${{ inputs.upload_extension }} | |
name: Upload Extension | |
needs: [main] | |
environment: | |
name: ${{inputs.environment}} | |
url: 'https://chrome.google.com/webstore/devconsole/98df2dba-c751-4acf-a79a-af687cb603df' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: nx-main-artifacts | |
- name: Upload & release | |
uses: mnao305/chrome-extension-upload@v5.0.0 | |
id: chrome-extension-upload | |
with: | |
file-path: acf-extension.zip | |
extension-id: ${{ vars.NX_CHROME_EXTENSION_ID }} | |
client-id: ${{ secrets.CLIENT_ID }} | |
client-secret: ${{ secrets.CLIENT_SECRET }} | |
refresh-token: ${{ secrets.REFRESH_TOKEN }} | |
publish: ${{inputs.publish_extension}} | |
glob: true | |
web: | |
if: ${{ inputs.deploy_web }} | |
name: Deploy Web | |
needs: [main] | |
permissions: | |
contents: read | |
pull-requests: write | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{inputs.environment}} | |
url: ${{vars.PUBLIC_URL}} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: nx-main-artifacts | |
- name: Build And Deploy | |
if: ${{ hashFiles('acf-options-page/') != '' }} | |
id: deploy | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) | |
action: 'upload' | |
###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### | |
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig | |
app_location: 'acf-options-page' # App source code path | |
api_location: '' # Api source code path - optional | |
skip_app_build: true | |
skip_api_build: true | |
output_location: '' # Built app content directory - optional | |
###### End of Repository/Build Configurations ###### | |
release: | |
if: ${{ inputs.release }} | |
name: Release | |
needs: [extension, web] | |
environment: | |
name: ${{inputs.environment}} | |
url: ${{steps.release.outputs.url}} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
discussions: write | |
outputs: | |
release-url: ${{ steps.release.outputs.url }} | |
release-id: ${{ steps.release.outputs.id }} | |
release-upload_url: ${{ steps.release.outputs.upload_url }} | |
release-assets: ${{ steps.release.outputs.assets }} | |
steps: | |
- uses: softprops/action-gh-release@v2 | |
id: release | |
with: | |
token: ${{ secrets.REPO_PAT }} # Use the PAT here | |
prerelease: ${{ vars.NX_VARIANT == 'BETA' || vars.NX_VARIANT == 'DEV'}} | |
repository: Dhruv-Techapps/acf-docs | |
generate_release_notes: true | |
discussion_category_name: 'Release' | |
fail_on_unmatched_files: true | |
tag: | |
needs: [extension, web] | |
name: Create tag | |
runs-on: ubuntu-latest | |
environment: ${{inputs.environment}} | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set ${{vars.NX_VARIANT}} Tag | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
force_push_tag: true | |
tag: '${{vars.NX_VARIANT}}' |