switch from azure-pipelines to github actions
This commit is contained in:
parent
6ca62dba6e
commit
4edec7c4b7
15 changed files with 130 additions and 105 deletions
3
.editorconfig
Normal file
3
.editorconfig
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline=true
|
||||||
|
indent_size = 2
|
31
.gitattributes
vendored
31
.gitattributes
vendored
|
@ -1,9 +1,22 @@
|
||||||
# Auto detect text files and perform LF normalization
|
# Text files crlf
|
||||||
* text eol=crlf
|
*.html text eol=crlf
|
||||||
*.html text
|
*.json text eol=crlf
|
||||||
*.css text
|
*.js text eol=crlf
|
||||||
*.xml text
|
*.lock text eol=crlf
|
||||||
|
*.md text eol=crlf
|
||||||
*.png binary
|
*.ps1 text eol=crlf
|
||||||
*.zip binary
|
*.styl text eol=crlf
|
||||||
*.jpg binary
|
*.vue text eol=crlf
|
||||||
|
*.xml text eol=crlf
|
||||||
|
*.yml text eol=crlf
|
||||||
|
|
||||||
|
# Special files
|
||||||
|
.dockerignore text eol=crlf
|
||||||
|
.prettierrc text eol=crlf
|
||||||
|
Dockerfile text eol=crlf
|
||||||
|
LICENSE text eol=crlf
|
||||||
|
|
||||||
|
# Binary files
|
||||||
|
*.jpg binary
|
||||||
|
*.png binary
|
||||||
|
*.zip binary
|
||||||
|
|
31
.github/workflows/default.yml
vendored
Normal file
31
.github/workflows/default.yml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
name: Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
- '!gh-pages'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create a new build
|
||||||
|
run: docker build -t publisher:latest -f ./dockerfiles/Deploy.Dockerfile .
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
steps:
|
||||||
|
- name: Deploy to gh-pages branch
|
||||||
|
env:
|
||||||
|
GITHUB_PAT: ${{ secrets.GITHUB_PAT }}
|
||||||
|
PUBLISHER_NAME: ${{ secrets.PUBLISHER_NAME }}
|
||||||
|
PUBLISHER_EMAIL: ${{ secrets.PUBLISHER_EMAIL }}
|
||||||
|
run: |
|
||||||
|
docker run \
|
||||||
|
--rm \
|
||||||
|
-e GITHUB_PAT="$env:GITHUB_PAT" \
|
||||||
|
-e PUBLISHER_NAME="$env:PUBLISHER_NAME" \
|
||||||
|
-e PUBLISHER_EMAIL="$env:PUBLISHER_EMAIL" \
|
||||||
|
publisher:latest
|
|
@ -1,39 +0,0 @@
|
||||||
trigger:
|
|
||||||
branches:
|
|
||||||
include:
|
|
||||||
- master
|
|
||||||
|
|
||||||
pr: none
|
|
||||||
|
|
||||||
pool:
|
|
||||||
vmImage: "windows-latest"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: "Update archives"
|
|
||||||
inputs:
|
|
||||||
targetType: "filePath"
|
|
||||||
filePath: "./update_archives.azure.ps1"
|
|
||||||
failOnStderr: true
|
|
||||||
workingDirectory: $(Build.SourcesDirectory)
|
|
||||||
- task: NodeTool@0
|
|
||||||
displayName: "Setup node 12.x"
|
|
||||||
inputs:
|
|
||||||
versionSpec: "12.x"
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: "Create Build"
|
|
||||||
inputs:
|
|
||||||
targetType: "filePath"
|
|
||||||
filePath: "./build.azure.ps1"
|
|
||||||
failOnStderr: true
|
|
||||||
workingDirectory: $(Build.SourcesDirectory)
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: "Push Changes"
|
|
||||||
condition: succeeded()
|
|
||||||
env:
|
|
||||||
GitHub_PAT: $(GitHub_PAT)
|
|
||||||
inputs:
|
|
||||||
targetType: "inline"
|
|
||||||
script: "git push -uqf $(GitHub_PAT) HEAD:gh-pages;"
|
|
||||||
failOnStderr: true
|
|
||||||
workingDirectory: $(Build.SourcesDirectory)/docs/.vuepress/dist
|
|
|
@ -1,20 +0,0 @@
|
||||||
$ErrorActionPreference = "Stop";
|
|
||||||
|
|
||||||
Write-Host -ForegroundColor Blue "Ensuring yarn is installed..";
|
|
||||||
npm i -g yarn;
|
|
||||||
|
|
||||||
Write-Host -ForegroundColor Blue "Installing dependencies..";
|
|
||||||
yarn;
|
|
||||||
|
|
||||||
Write-Host -ForegroundColor Blue "Creating new build..";
|
|
||||||
yarn build;
|
|
||||||
|
|
||||||
Write-Host -ForegroundColor Blue "Initializing git repository";
|
|
||||||
$Remote = (git remote get-url origin);
|
|
||||||
Set-Location "./docs/.vuepress/dist";
|
|
||||||
git init;
|
|
||||||
git config --local user.name "BotPatty";
|
|
||||||
git config --local user.email "ci@zint.ch";
|
|
||||||
git remote add origin $Remote;
|
|
||||||
git add .;
|
|
||||||
git commit -m "auto-deployment";
|
|
|
@ -5,7 +5,7 @@ services:
|
||||||
container_name: gct_generator
|
container_name: gct_generator
|
||||||
build:
|
build:
|
||||||
context: ./
|
context: ./
|
||||||
dockerfile: Dockerfile
|
dockerfile: ./dockerfiles/Serve.Dockerfile
|
||||||
network_mode: 'bridge'
|
network_mode: 'bridge'
|
||||||
ports:
|
ports:
|
||||||
- '8080:80'
|
- '8080:80'
|
||||||
|
|
22
dockerfiles/Deploy.Dockerfile
Normal file
22
dockerfiles/Deploy.Dockerfile
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
ARG GITHUB_PAT
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/powershell:latest AS prebuild
|
||||||
|
WORKDIR /src
|
||||||
|
COPY . .
|
||||||
|
RUN pwsh -File ./scripts/build_archives.ps1
|
||||||
|
|
||||||
|
FROM node:lts-buster AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY --from=prebuild /src .
|
||||||
|
RUN yarn
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/powershell:latest AS final
|
||||||
|
ARG GITHUB_PAT
|
||||||
|
ENV GITHUB_PAT ${GITHUB_PAT}
|
||||||
|
WORKDIR /src
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt install -y git
|
||||||
|
COPY ./scripts/deploy.ps1 ./deploy.ps1
|
||||||
|
COPY --from=build /src/docs/.vuepress/dist ./dist
|
||||||
|
CMD [ "pwsh", "deploy.ps1" ]
|
|
@ -1,6 +1,11 @@
|
||||||
FROM node:lts-buster AS build
|
FROM mcr.microsoft.com/powershell:latest AS prebuild
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN pwsh -File ./scripts/build_archives.ps1
|
||||||
|
|
||||||
|
FROM node:lts-buster AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY --from=prebuild /src .
|
||||||
RUN yarn
|
RUN yarn
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
0
docs/.vuepress/public/files/.gitkeep
Normal file
0
docs/.vuepress/public/files/.gitkeep
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,35 +1,16 @@
|
||||||
|
# Stop on errors
|
||||||
$ErrorActionPreference = "Stop";
|
$ErrorActionPreference = "Stop";
|
||||||
|
|
||||||
# Retrieve commit hash from latest archive update
|
# Hide progress bars
|
||||||
Write-Host -ForegroundColor Blue "Retrieving last update commit..";
|
$global:ProgressPreference = 'SilentlyContinue'
|
||||||
$LastGCMUpdate = (git log -1 --pretty=format:"%H" ./docs/.vuepress/public/files/GCMCodes.zip);
|
|
||||||
|
|
||||||
if ([string]::IsNullOrWhiteSpace($LastGCMUpdate)) {
|
|
||||||
Write-Host -ForegroundColor Red "Failed to retrieve the latest update commit";
|
|
||||||
exit -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host -ForegroundColor Green "Last GCM Archive Update:" $LastGCMUpdate;
|
|
||||||
|
|
||||||
# Check whether any one of the code files chnged
|
|
||||||
Write-Host -ForegroundColor Blue "Scanning for code changes.."
|
|
||||||
|
|
||||||
$CodeUpdates = (git diff --name-only $LastGCMUpdate HEAD -- './docs/.vuepress/public/codes/*.xml')
|
|
||||||
|
|
||||||
if ([string]::IsNullOrWhiteSpace($CodeUpdates)) {
|
|
||||||
Write-Host -ForegroundColor Green "No code changes detected";
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Changed files since last archive Update:" $CodeUpdates;
|
|
||||||
|
|
||||||
# Start build
|
# Start build
|
||||||
Write-Host -ForegroundColor Blue "Packing new archive...";
|
Write-Host "Packing archives...";
|
||||||
|
|
||||||
# Setup workspace
|
# Setup workspace
|
||||||
New-Item -ItemType directory -Path "./.build";
|
New-Item -ItemType directory -Path "./tmp" > $null;
|
||||||
Copy-Item "./docs/.vuepress/public/codes/*.xml" "./.build/";
|
Copy-Item "./docs/.vuepress/public/codes/*.xml" "./tmp/";
|
||||||
Set-Location "./.build";
|
Set-Location "./tmp";
|
||||||
|
|
||||||
# Helper function to convert the XML files to the GCM txt format
|
# Helper function to convert the XML files to the GCM txt format
|
||||||
function XmlToGcm($source, $destination, $versionname) {
|
function XmlToGcm($source, $destination, $versionname) {
|
||||||
|
@ -70,10 +51,9 @@ XmlToGcm "GMSJ01.xml" "GMSJ01.txt" "GMSJ01";
|
||||||
XmlToGcm "GMSJ0A.xml" "GMSJ01 (A).txt" "GMSJ01";
|
XmlToGcm "GMSJ0A.xml" "GMSJ01 (A).txt" "GMSJ01";
|
||||||
|
|
||||||
# Replace zip file
|
# Replace zip file
|
||||||
Write-Host "Compressing and replacing GCM archive..";
|
Write-Host "Compressing GCM archive..";
|
||||||
Compress-Archive "./*.txt" "../docs/.vuepress/public/files/GCMCodes.zip" -Force;
|
Compress-Archive "./*.txt" "../docs/.vuepress/public/files/GCMCodes.zip";
|
||||||
|
Write-Host "GCM Archive built";
|
||||||
Write-Host -ForegroundColor Green "GCM Archive rebuilt";
|
|
||||||
|
|
||||||
# Convert files to Dolphin format
|
# Convert files to Dolphin format
|
||||||
Remove-Item *.txt;
|
Remove-Item *.txt;
|
||||||
|
@ -84,13 +64,13 @@ XmlToIni "GMSP01.xml" "GMSP01.txt" "GMSP01";
|
||||||
XmlToIni "GMSJ01.xml" "GMSJ01.txt" "GMSJ01";
|
XmlToIni "GMSJ01.xml" "GMSJ01.txt" "GMSJ01";
|
||||||
XmlToIni "GMSJ0A.xml" "GMSJ01 (A).txt" "GMSJ01";
|
XmlToIni "GMSJ0A.xml" "GMSJ01 (A).txt" "GMSJ01";
|
||||||
|
|
||||||
Write-Host "Compressing and replacing Dolphin archive..";
|
Write-Host "Compressing Dolphin archive..";
|
||||||
Compress-Archive "./*.txt" "../docs/.vuepress/public/files/DolphinCodes.zip" -Force;
|
Compress-Archive "./*.txt" "../docs/.vuepress/public/files/DolphinCodes.zip";
|
||||||
|
|
||||||
Write-Host -ForegroundColor Green "Dolphin Archive rebuilt";
|
Write-Host "Dolphin Archive built";
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
Write-Host "Cleaning up..";
|
Write-Host "Cleaning up..";
|
||||||
Set-Location ..;
|
Set-Location ..;
|
||||||
Remove-Item "./.build" -Recurse;
|
Remove-Item "./tmp" -Recurse;
|
||||||
Write-Host -ForegroundColor Green "Done";
|
Write-Host "Done";
|
30
scripts/deploy.ps1
Normal file
30
scripts/deploy.ps1
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# Stop on errors
|
||||||
|
$ErrorActionPreference = "Stop";
|
||||||
|
Set-StrictMode -Version Latest
|
||||||
|
|
||||||
|
# Hide progress bars
|
||||||
|
$global:ProgressPreference = 'SilentlyContinue';
|
||||||
|
|
||||||
|
Set-Location "./dist"
|
||||||
|
|
||||||
|
# Set git email and username
|
||||||
|
Write-Host "Configuring git"
|
||||||
|
git init
|
||||||
|
git config --local user.name "$env:PUBLISHER_NAME" | Out-Null;
|
||||||
|
git config --local user.email "$env:PUBLISHER_EMAIL" | Out-Null;
|
||||||
|
|
||||||
|
# Commit all files in the dist/ directory
|
||||||
|
Write-Host "Commiting build"
|
||||||
|
git add .;
|
||||||
|
git commit -m "auto-deployment";
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Force push to gh-pages
|
||||||
|
Write-Host "Pushing to gh-pages branch";
|
||||||
|
git push -uqf $env:GITHUB_PAT HEAD:gh-pages 2>&1 | Out-Null;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "Push failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Finished";
|
Loading…
Reference in a new issue