dotnet #826
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: dotnet | |
on: | |
push: | |
paths: | |
- "samples/dotnet/**" | |
- ".github/workflows/dotnet.yml" | |
- "restarter/**" | |
schedule: | |
- cron: '0 7 * * *' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: miracl/oidc-samples/samples/dotnet | |
DOCKER_BUILD_CONTEXT: samples/dotnet | |
SAMPLE_IMAGE: ghcr.io/miracl/oidc-samples/samples/dotnet:${{ github.sha }} | |
PROXY_IMAGE: ghcr.io/miracl/oidc-samples/proxy:latest-windows | |
TESTS_IMAGE: ghcr.io/miracl/oidc-samples/integration-tests:latest-windows | |
CLIENT_ID: ${{ vars.CLIENT_ID }} | |
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} | |
PROJECT_ID: ${{ vars.PROJECT_ID }} | |
CID_FILE: sample.cid | |
jobs: | |
build-dotnet: | |
runs-on: windows-2019 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v1 | |
- name: Setup NuGet | |
uses: NuGet/[email protected] | |
- name: Setup VSTest | |
uses: darenm/Setup-VSTest@v1 | |
- name: Restore Packages | |
run: nuget restore samples/dotnet/OidcSample.sln | |
- name: Build Solution | |
run: | | |
msbuild.exe samples/dotnet/OidcSample.sln /p:platform="Any CPU" /p:configuration="Release" | |
build-docker: | |
needs: build-dotnet | |
runs-on: windows-2019 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=${{ github.sha }} | |
- name: Docker login, build & push | |
run: | | |
docker build --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest samples/dotnet/ | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest ${{ steps.meta.outputs.tags}} | |
docker push ${{ steps.meta.outputs.tags}} | |
run-integration-tests-with-proxy: | |
needs: build-docker | |
runs-on: windows-2019 | |
steps: | |
- name: Pull images | |
run: | | |
docker pull --quiet ${{ env.PROXY_IMAGE }} | |
docker pull --quiet ${{ env.SAMPLE_IMAGE }} | |
docker pull --quiet ${{ env.TESTS_IMAGE }} | |
- name: Start the proxy | |
run: docker run | |
--detach | |
--publish 8080:8080 | |
--cidfile ${{ env.CID_FILE }} | |
${{ env.PROXY_IMAGE }} | |
- name: Checkout repository content | |
uses: actions/checkout@v3 | |
- name: Run the restarter | |
run: go run ./restarter/main.go & | |
- name: Sleep for a seconds | |
run: sleep 1s | |
shell: bash | |
- name: Proxy info | |
id: proxy | |
shell: bash | |
run: | | |
export CID=$(cat $CID_FILE) | |
export ADDR=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CID) | |
echo "::set-output name=address::$ADDR" | |
rm -rf $CID_FILE | |
- name: Start the sample | |
shell: bash | |
run: docker run | |
--detach | |
--publish 8000:8000 | |
--name sample | |
--env CLIENT_ID | |
--env CLIENT_SECRET | |
--env REDIRECT_URL=http://sample:8000/login | |
--env PROXY_HOST=${{ steps.proxy.outputs.address }} | |
--env PROXY_PORT=8080 | |
--cidfile $CID_FILE | |
${{ env.SAMPLE_IMAGE }} | |
- name: Sleep for 10 seconds | |
run: sleep 10s | |
shell: bash | |
- name: Sample info | |
id: sample | |
shell: bash | |
run: | | |
export CID=$(cat $CID_FILE) | |
export ADDR=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CID) | |
echo "::set-output name=address::$ADDR" | |
- name: Run integration tests | |
id: tests | |
shell: powershell | |
run: docker run | |
--env CLIENT_ID | |
--env CLIENT_SECRET | |
--env PROJECT_ID | |
--env SAMPLE_NAME=sample | |
--env SAMPLE_IP=${{ steps.sample.outputs.address }} | |
--env SAMPLE_URL=http://sample:8000 | |
--env REDIRECT_URL=http://sample:8000/login | |
--env SKIP_MODIFY_TESTS=false | |
${{ env.TESTS_IMAGE }} | |
run-integration-tests: | |
needs: build-docker | |
runs-on: windows-2019 | |
steps: | |
- name: Pull images | |
run: | | |
docker pull --quiet ${{ env.SAMPLE_IMAGE }} | |
docker pull --quiet ${{ env.TESTS_IMAGE }} | |
- name: Start the sample | |
shell: bash | |
run: docker run | |
--detach | |
--publish 8000:8000 | |
--env CLIENT_ID | |
--env CLIENT_SECRET | |
--env REDIRECT_URL=http://sample:8000/login | |
--cidfile $CID_FILE | |
${{ env.SAMPLE_IMAGE }} | |
- name: Sleep for 1 seconds | |
run: sleep 2s | |
shell: bash | |
- name: Info | |
id: info | |
shell: bash | |
run: | | |
export CID=$(cat $CID_FILE) | |
export ADDR=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CID) | |
echo "::set-output name=address::$ADDR" | |
- name: Run integration tests | |
id: tests | |
shell: powershell | |
run: docker run | |
--env CLIENT_ID | |
--env CLIENT_SECRET | |
--env PROJECT_ID | |
--env SAMPLE_IP=${{ steps.info.outputs.address }} | |
--env SAMPLE_URL=http://sample:8000 | |
--env REDIRECT_URL=http://sample:8000/login | |
--env SKIP_MODIFY_TESTS=true | |
${{ env.TESTS_IMAGE }} |