Skip to content

feat: Publish docker image of reference implementation #784

feat: Publish docker image of reference implementation

feat: Publish docker image of reference implementation #784

name: Ref Impl
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test-server:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
- name: Build OpenActive.Server.NET.Tests and dependencies
run: dotnet build ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release
- name: Run OpenActive.Server.NET.Tests
run: dotnet test ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release --no-build --verbosity normal
test-fake-database:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
- name: Build OpenActive.FakeDatabase.NET.Tests
run: dotnet build ./Fakes/OpenActive.FakeDatabase.NET.Tests/OpenActive.FakeDatabase.NET.Tests.csproj --configuration Release
- name: Run OpenActive.FakeDatabase.NET.Tests
run: dotnet test ./Fakes/OpenActive.FakeDatabase.NET.Tests/OpenActive.FakeDatabase.NET.Tests.csproj --configuration Release --no-build --verbosity normal
core:
needs:
- test-server
- test-fake-database
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mode: ['random', 'controlled']
profile: ['all-features', 'single-seller', 'no-payment-reconciliation', 'no-auth', 'no-tax-calculation', 'prepayment-always-required', 'facilityuse-has-slots']
steps:
- name: Checkout OpenActive.Server.NET
uses: actions/checkout@v2
with:
path: server
- name: Use matching coverage/* branch ${{ github.head_ref }} in OpenActive Test Suite
if: ${{ startsWith(github.head_ref, 'coverage/') }}
id: refs
run: echo "::set-output name=mirror_ref::${{ github.head_ref }}"
- name: Checkout OpenActive Test Suite ${{ steps.refs.outputs.mirror_ref }}
uses: actions/checkout@v2
with:
repository: openactive/openactive-test-suite
ref: ${{ steps.refs.outputs.mirror_ref }}
path: tests
- name: Setup .NET Core SDK 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
- name: Setup Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install OpenActive.Server.NET dependencies
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
run: dotnet restore ./server/
- name: Build .NET Core Authentication Authority Reference Implementation
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
run: dotnet build ./server/Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-restore
- name: Start .NET Core Authentication Authority Reference Implementation
if: ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' }}
run: |
dotnet run --no-launch-profile --project ./server/Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-build &
- name: Build .NET Core Booking Server Reference Implementation
run: dotnet build ./server/Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release ${{ matrix.profile != 'no-auth' && matrix.profile != 'single-seller' && '--no-restore' || '' }}
- name: Start .NET Core Booking Server Reference Implementation
run: |
dotnet run --no-launch-profile --project ./server/Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release --no-build &
env:
ASPNETCORE_ENVIRONMENT: ${{ matrix.profile }}
- name: Install OpenActive Test Suite
run: npm install
working-directory: tests
- name: Run OpenActive Integration Tests in ${{ matrix.mode }} mode
run: npm start
env:
FORCE_COLOR: 1
NODE_CONFIG: |
{"broker": {"outputPath": "../../output/"}, "integrationTests": { "outputPath": "../../output/", "conformanceCertificatePath": "../../conformance/examples/${{ matrix.profile }}/${{ matrix.mode }}/", "useRandomOpportunities": ${{ matrix.mode == 'random' }}, "conformanceCertificateId": "https://certificates.reference-implementation.openactive.io/examples/${{ matrix.profile }}/${{ matrix.mode }}/" }}
NODE_ENV: .example.${{ matrix.profile }}
NODE_APP_INSTANCE: ci
working-directory: tests
- name: Upload test output for ${{ matrix.mode }} mode as artifact
uses: actions/upload-artifact@v2
if: ${{ success() || failure() }}
with:
name: core.${{ matrix.mode }}.${{ matrix.profile }}
path: ./tests/output/
- name: Deploy conformance certificate to Azure Blob Storage (master branch for 'all-features' profile in controlled mode only)
uses: bacongobbler/[email protected]
if: ${{ github.ref == 'refs/heads/master' }}
with:
source_dir: ./tests/conformance/
container_name: '$web'
connection_string: ${{ secrets.CONFORMANCE_CERTIFICATE_BLOB_STORAGE_CONNECTION_STRING }}
sync: false
framework:
needs:
- test-server
- test-fake-database
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
mode: ['random', 'controlled']
profile: ['no-auth']
steps:
- name: Checkout OpenActive.Server.NET
uses: actions/checkout@v2
with:
path: server
- name: Use matching coverage/* branch ${{ github.head_ref }} in OpenActive Test Suite
if: ${{ startsWith(github.head_ref, 'coverage/') }}
id: refs
run: echo "::set-output name=mirror_ref::${{ github.head_ref }}"
- name: Checkout OpenActive Test Suite ${{ steps.refs.outputs.mirror_ref }}
uses: actions/checkout@v2
with:
repository: openactive/openactive-test-suite
ref: ${{ steps.refs.outputs.mirror_ref }}
path: tests
- name: Setup Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Setup MSBuild path
uses: microsoft/[email protected]
- name: Setup NuGet
uses: NuGet/[email protected]
- name: Install OpenActive.Server.NET dependencies
run: nuget restore .\server\
- name: Build .NET Framework Reference Implementation
run: msbuild .\server\Examples\BookingSystem.AspNetFramework\BookingSystem.AspNetFramework.csproj /p:Configuration=Release
- name: Deploy .NET Framework Reference Implementation to folder
run: msbuild .\server\Examples\BookingSystem.AspNetFramework\BookingSystem.AspNetFramework.csproj /p:Configuration=Release /p:DeployOnBuild=true /t:WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl=${{ runner.temp }}\deploy\ /p:PackageAsSingleFile=false
- name: Start .NET Framework Reference Implementation from folder (using IIS Express)
run: |
Start-Process -FilePath "$Env:Programfiles\IIS Express\iisexpress.exe" -ArgumentList "/path:${{ runner.temp }}\deploy\ /port:5000"
- name: Install OpenActive Test Suite
run: npm install
working-directory: tests
- name: Run OpenActive Integration Tests in ${{ matrix.mode }} mode
run: npm start
env:
FORCE_COLOR: 1
NODE_CONFIG: |
{"broker": {"outputPath": "../../output/"}, "integrationTests": {"outputPath": "../../output/", "useRandomOpportunities": ${{ matrix.mode == 'random' }}, "conformanceCertificateId": "https://openactive.io/OpenActive.Server.NET/certification/"}}
NODE_ENV: .example.${{ matrix.profile }}
NODE_APP_INSTANCE: framework
working-directory: tests
- name: Upload test output for ${{ matrix.mode }} mode as artifact
uses: actions/upload-artifact@v2
if: ${{ success() || failure() }}
with:
name: framework.${{ matrix.mode }}.${{ matrix.profile }}
path: ./tests/output/
deploy-reference-implementation:
# Master branch only
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- core
runs-on: ubuntu-latest
steps:
# Checkout the repo
- uses: actions/checkout@master
# Setup .NET Core SDK
- name: Setup .NET Core SDK 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
# Run dotnet build and publish
- name: Install OpenActive.Server.NET dependencies
run: dotnet restore
- name: Build OpenActive.Server.NET Booking Server Reference Implementation
run: dotnet build ./Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release --no-restore
- name: Publish OpenActive.Server.NET Booking Server Reference Implementation
run: dotnet publish ./Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj --configuration Release --no-build --output './web-app-package/BookingSystem.AspNetCore'
- name: Build OpenActive.Server.NET Authentication Authority Reference Implementation
run: dotnet build ./Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-restore
- name: Publish OpenActive.Server.NET Authentication Authority Reference Implementation
run: dotnet publish ./Examples/BookingSystem.AspNetCore.IdentityServer/BookingSystem.AspNetCore.IdentityServer.csproj --configuration Release --no-build --output './web-app-package/BookingSystem.AspNetCore.IdentityServer'
# Deploy to Azure Web apps
- name: 'Deploy Booking Server Reference Implementation using publish profile credentials'
uses: azure/webapps-deploy@v2
with:
app-name: openactive-reference-implementation
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation
package: './web-app-package/BookingSystem.AspNetCore'
- name: 'Deploy Authentication Authority Reference Implementation using publish profile credentials'
uses: azure/webapps-deploy@v2
with:
app-name: openactive-reference-implementation-auth
publish-profile: ${{ secrets.AZURE_WEBAPP_AUTH_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation
package: './web-app-package/BookingSystem.AspNetCore.IdentityServer'
publish-server:
# Master branch only
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- core
- framework
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Install Nerdbank.GitVersioning
run: cp Directory.Build.props.template Directory.Build.props
- name: Get current version
uses: dotnet/nbgv@master
id: nbgv
- name: Setup .NET Core 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build ./OpenActive.Server.NET/OpenActive.Server.NET.csproj --configuration Release --no-restore
- name: Test
run: dotnet test ./OpenActive.Server.NET.Tests/OpenActive.Server.NET.Tests.csproj --configuration Release --no-restore --verbosity normal
- name: Pack
run: dotnet pack ./OpenActive.Server.NET/OpenActive.Server.NET.csproj --configuration Release --include-source --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
- name: Push to Nuget
if: "! contains(toJSON(github.event.commits.*.message), '[no-release]')"
run: dotnet nuget push "./OpenActive.Server.NET/**/*.nupkg" -k ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json
- name: Create Release
if: "! contains(toJSON(github.event.commits.*.message), '[no-release]')"
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.nbgv.outputs.SimpleVersion }}
release_name: Release ${{ steps.nbgv.outputs.SimpleVersion }}
body: |
This release contains minor amendments based on updates to the [OpenActive Vocabulary](https://openactive.io/ns/) (codified by the [Data Models](https://github.com/openactive/data-models)), and the latest version of the [Dataset Site Template](https://github.com/openactive/dataset-site-template).
Published to Nuget: [OpenActive.Server.NET](https://www.nuget.org/packages/OpenActive.Server.NET/${{ steps.nbgv.outputs.SimpleVersion }}) and [OpenActive.FakeDatabase.NET](https://www.nuget.org/packages/OpenActive.FakeDatabase.NET/${{ steps.nbgv.outputs.SimpleVersion }}).
Published to GitHub Container Registry: [reference.bookingsystem](https://github.com/openactive/OpenActive.Server.NET/pkgs/container/reference.bookingsystem) and [reference.bookingsystem.identity](https://github.com/openactive/OpenActive.Server.NET/pkgs/container/reference.bookingsystem.identity)
draft: false
prerelease: false
publish-fake-database:
# Master branch only
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- core
- framework
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Install Nerdbank.GitVersioning
run: cp Directory.Build.props.template Directory.Build.props
- name: Get current version
uses: dotnet/nbgv@master
id: nbgv
- name: Setup .NET Core 3.1.419
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.419
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build ./Fakes/OpenActive.FakeDatabase.NET/OpenActive.FakeDatabase.NET.csproj --configuration Release --no-restore
- name: Test
run: dotnet test ./Fakes/OpenActive.FakeDatabase.NET.Tests/OpenActive.FakeDatabase.NET.Tests.csproj --configuration Release --no-restore --verbosity normal
- name: Pack
run: dotnet pack ./Fakes/OpenActive.FakeDatabase.NET/OpenActive.FakeDatabase.NET.csproj --configuration Release --include-source --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
- name: Push to Nuget
if: "! contains(toJSON(github.event.commits.*.message), '[no-release]')"
run: dotnet nuget push "./Fakes/OpenActive.FakeDatabase.NET/**/*.nupkg" -k ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json
build-and-push-docker-image:
# Publish to GitHub Container Registry
# Master branch only
# if: ${{ github.ref == 'refs/heads/master' }}
# needs:
# - core
# - framework
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
# IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Install Nerdbank.GitVersioning
run: cp Directory.Build.props.template Directory.Build.props
- name: Get current version
uses: dotnet/nbgv@master
id: nbgv
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Booking System
id: meta-booking
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/OpenActive/Reference.BookingSystem
labels: |
org.opencontainers.image.title=OpenActive Reference Implementation - Booking System
org.opencontainers.image.description=Reference Implementation for OpenActive data publishing and Open Booking API implementation
org.opencontainers.image.vendor=OpenActive
tags: |
type=semver,pattern={{version}},value=v${{ steps.nbgv.outputs.SimpleVersion }}
- name: Extract metadata (tags, labels) for Identity Server
id: meta-id
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/OpenActive/Reference.BookingSystem.Identity
labels: |
org.opencontainers.image.title=OpenActive Reference Implementation - Identity Server
org.opencontainers.image.description=Reference Implementation for OpenID Connect implementation for OpenActive
org.opencontainers.image.vendor=OpenActive
tags: |
type=semver,pattern={{version}},value=v${{ steps.nbgv.outputs.SimpleVersion }}
- name: Build and push Docker image for Booking System
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta-booking.outputs.tags }}
labels: ${{ steps.meta-booking.outputs.labels }}
target: booking-server
- name: Build and push Docker image for Identity Server
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta-id.outputs.tags }}
labels: ${{ steps.meta-id.outputs.labels }}
target: identity-server