Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions src/main/resources/nubesgen/.github/workflows/gitops.yml.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ env:
DOTNET_VERSION: '3.1'
APP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
<%/runtimeDotnet%>
<%#runtimeNodejs%>

env:
NODEJS_VERSION: '14'
APP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
<%/runtimeNodejs%>
<%#runtimeDocker%>

env:
Expand Down Expand Up @@ -321,33 +327,55 @@ jobs:
<%/applicationTypeFunction%>
<%/runtimeDotnet%>
<%#runtimeNodejs%>
build-and-deploy:
needs: manage-infrastructure
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use Node.js
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: ${{ env.NODEJS_VERSION }}
- name: Cache NPM packages
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM
- name: Install NPM packages
run: npm ci
- name: Build the application
run: npm run build
run: npm run build --if-present
Comment thread
cmaneu marked this conversation as resolved.
- name: Run tests
run: npm run test
run: npm test --if-present
- name: Package application
run: |
PKG_FILE=$(npm pack ${{ env.APP_PACKAGE_PATH }} | tail -n1)
tar -xvf $PKG_FILE
cp -f ${{ env.APP_PACKAGE_PATH }}/package-lock.json package/
Comment thread
sinedied marked this conversation as resolved.
cd package
npm ci --production
zip -r package.zip *
- name: Temporarily save package
uses: actions/upload-artifact@v2
with:
name: package
path: './package'
retention-days: 1
deploy:
needs: [manage-infrastructure, build]
runs-on: ubuntu-20.04
steps:
- name: Set environment variables
run: |
TAG_NAME=${GITHUB_REF#refs/*/}
echo "ENVIRONMENT=${TAG_NAME:4}" >> $GITHUB_ENV
- name: Get built package
uses: actions/download-artifact@v2
with:
name: package
path: ./package
- name: Login to Azure
uses: azure/login@v1
with:
Expand All @@ -357,13 +385,13 @@ jobs:
uses: azure/webapps-deploy@v2
with:
app-name: app-<% applicationName %>-${{ env.ENVIRONMENT }}-001
package: '.'
package: './package/package.zip'
<%/applicationTypeAppService%>
<%#applicationTypeFunction%>
- name: 'Deploy to Azure Functions'
uses: Azure/functions-action@v1
with:
app-name: func-<% applicationName %>-${{ env.ENVIRONMENT }}-001
package: '.'
package: './package/package.zip'
<%/applicationTypeFunction%>
<%/runtimeNodejs%>
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ resource "azurerm_app_service" "application" {

app_settings = {
"WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
{{#runtimeNodejs}}
"WEBSITE_RUN_FROM_PACKAGE" = "1"
"WEBSITE_NODE_DEFAULT_VERSION" = "~14"
{{/runtimeNodejs}}
{{#runtimeDocker}}
"DOCKER_REGISTRY_SERVER_URL" = "https://${azurerm_container_registry.container-registry.name}.azurecr.io"
"DOCKER_REGISTRY_SERVER_USERNAME" = azurerm_container_registry.container-registry.admin_username
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
branches:
- 'env-*'

env:
NODEJS_VERSION: '14'
APP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root

jobs:
manage-infrastructure:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -53,33 +57,55 @@ jobs:
-auto-approve \
-var="environment=$ENVIRONMENT"
working-directory: '${{ github.workspace }}/terraform'
build-and-deploy:
needs: manage-infrastructure
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use Node.js
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: ${{ env.NODEJS_VERSION }}
- name: Cache NPM packages
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM
- name: Install NPM packages
run: npm ci
- name: Build the application
run: npm run build
run: npm run build --if-present
- name: Run tests
run: npm run test
run: npm test --if-present
- name: Package application
run: |
PKG_FILE=$(npm pack ${{ env.APP_PACKAGE_PATH }} | tail -n1)
tar -xvf $PKG_FILE
cp -f ${{ env.APP_PACKAGE_PATH }}/package-lock.json package/
cd package
npm ci --production
zip -r package.zip *
- name: Temporarily save package
uses: actions/upload-artifact@v2
with:
name: package
path: './package'
retention-days: 1
deploy:
needs: [manage-infrastructure, build]
runs-on: ubuntu-20.04
steps:
- name: Set environment variables
run: |
TAG_NAME=${GITHUB_REF#refs/*/}
echo "ENVIRONMENT=${TAG_NAME:4}" >> $GITHUB_ENV
- name: Get built package
uses: actions/download-artifact@v2
with:
name: package
path: ./package
- name: Login to Azure
uses: azure/login@v1
with:
Expand All @@ -88,4 +114,4 @@ jobs:
uses: azure/webapps-deploy@v2
with:
app-name: app-nubesgen-testapp-app-service-nodejs-${{ env.ENVIRONMENT }}-001
package: '.'
package: './package/package.zip'
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ resource "azurerm_app_service" "application" {

app_settings = {
"WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
"WEBSITE_RUN_FROM_PACKAGE" = "1"
"WEBSITE_NODE_DEFAULT_VERSION" = "~14"

# These are app specific environment variables
}
Expand Down