Skip to content

Deploy

Deploy #1754

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
inputs:
branch:
description: Branch to deploy to (default is main)
required: false
default: 'main'
copyToMain:
description: Additionally deploy templates to main+preview branch? (Y/N)
required: false
default: 'N'
schedule:
- cron: '0 23 * * *'
defaults:
run:
shell: pwsh
jobs:
Deploy:
runs-on: [ windows-latest ]
steps:
- uses: actions/checkout@v4.1.1
with:
ref: master
- name: CheckUser
run: |
if ("$ENV:GITHUB_REPOSITORY" -eq "fscpscollaborative/fscps" -and "$ENV:GITHUB_ACTOR" -ne "onikolaiev") {
Write-Host "::Error::You cannot run deploy and collect in the fscpscollaborative/fscps repo"
exit 1
}
- name: Deploy
run: |
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 2.0
try {
$token = '${{ Secrets.ORG_PAT }}'
if (!$token) {
throw "In order to run the Deploy workflow, you need a Secret called OrgPAT containing a valid Personal Access Token"
}
else {
$githubOwner = "$ENV:GITHUB_REPOSITORY_OWNER"
$settings = [ordered]@{
"githubOwner" = $githubOwner
"actionsRepo" = "fscps.gh"
"fscTemplateRepo" = "fscps.fsctpl"
"commerceTemplateRepo" = "fscps.commercetpl"
"ecommerceTemplateRepo" = "fscps.ecommercetpl"
"branch" = '${{ github.event.inputs.branch }}'
"copyToMain" = ('${{ github.event.inputs.copyToMain }}' -eq 'Y')
"localFolder" = ""
"baseFolder" = [System.IO.Path]::GetTempPath()
}
$settingsFile = Join-Path $settings.baseFolder "deploy.json"
$settings | ConvertTo-Json | Set-Content $settingsFile -Encoding UTF8
. ".\Internal\Deploy.ps1" -configName $settingsFile -githubOwner $githubOwner -token $token -github
}
}
catch {
Write-Host "::Error::Error deploying repositories. The error was $($_.Exception.Message)"
exit 1
}