forked from Nfactor26/pixel-identity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reuse-workflows-for-publish-to-docker-hub
correct references for local workflows cannot specify version when calling local workflows correct file name correct extensions to yaml while using workflow files Remove tagging during build Need to label at time of build rename tag to local during build image
- Loading branch information
Showing
6 changed files
with
193 additions
and
111 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Build docker image and upload as artificat | ||
|
||
on: [workflow_call] | ||
|
||
jobs: | ||
|
||
build-docker-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ secrets.DOCKERHUB_USERNAME }}/pixel-identity | ||
- name: Build docker image locally | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: ./ | ||
file: ./src/Pixel.Identity.Provider/Dockerfile | ||
push: false | ||
tags: pixel-identity:local | ||
labels: ${{ steps.meta.outputs.labels }} | ||
load: true | ||
- name: Upload docker image as artifcat | ||
uses: ishworkh/docker-image-artifact-upload@v1 | ||
with: | ||
image: "pixel-identity:local" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Publish image to docker hub on tag push to main | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
|
||
build-docker-image: | ||
uses: ./.github/workflows/identity-build-docker-image.yaml | ||
|
||
test-with-postgres-db: | ||
needs: build-docker-image | ||
uses: ./.github/workflows/identity-test-docker-image-with-postgres.yaml | ||
|
||
test-with-mongo-db: | ||
needs: build-docker-image | ||
uses: ./.github/workflows/identity-test-docker-image-with-mongo.yaml | ||
|
||
publish-to-docker-hub: | ||
needs: [test-with-postgres-db, test-with-mongo-db] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download and load docker image | ||
uses: ishworkh/docker-image-artifact-download@v1 | ||
with: | ||
image: "pixel-identity:local" | ||
- name: Login to docker hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Tag image | ||
run: docker tag pixel-identity:local ${{ secrets.DOCKERHUB_USERNAME }}/pixel-identity:${{ github.ref_name }} | ||
- name: Push image to docker hub | ||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/pixel-identity:${{ github.ref_name }} |
51 changes: 51 additions & 0 deletions
51
.github/workflows/identity-test-docker-image-with-mongo.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Identity build and test with docker image | ||
|
||
on: [workflow_call] | ||
|
||
jobs: | ||
|
||
test-with-mongo-db: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
dotnet-version: [ '6.0.x' ] | ||
|
||
services: | ||
mongo: | ||
image: mongo:latest | ||
env: | ||
MONGO_INITDB_ROOT_USERNAME: mongoadmin | ||
MONGO_INITDB_ROOT_PASSWORD: mongopass | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Download and load docker image | ||
uses: ishworkh/docker-image-artifact-download@v1 | ||
with: | ||
image: "pixel-identity:local" | ||
- name: Launch docker image | ||
run: > | ||
docker run -d -p 44382:80 --network=${{ job.container.network }} | ||
-e AllowedOrigins=http://localhost:44382 -e IdentityHost=http://localhost:44382/pauth | ||
--env-file ./.config/identity-mongo-with-console-email.env | ||
--name pixel_identity_provider pixel-identity:local | ||
- name: Print container details | ||
run: docker container ls | ||
- name: Setup dotnet ${{ matrix.dotnet-version }} | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{ matrix.dotnet-version }} | ||
- name: Build test project | ||
run: dotnet build src/Pixel.Identity.UI.Tests/Pixel.Identity.UI.Tests.csproj | ||
- name: print container logs | ||
run: docker logs pixel_identity_provider | ||
- name: Install browsers | ||
run: pwsh src/Pixel.Identity.UI.Tests/bin/Debug/net6.0/playwright.ps1 install | ||
- name: Execute tests | ||
run: dotnet test --logger "trx;" src/Pixel.Identity.UI.Tests/Pixel.Identity.UI.Tests.csproj | ||
- name: Upload test results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pixel-identity-mongo-automation-test-results-${{ matrix.os }} | ||
path: src/Pixel.Identity.UI.Tests/TestResults |
59 changes: 59 additions & 0 deletions
59
.github/workflows/identity-test-docker-image-with-postgres.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Test docker image with postgres backend | ||
|
||
on: [workflow_call] | ||
|
||
jobs: | ||
|
||
test-with-postgres-db: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
dotnet-version: [ '6.0.x' ] | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_USER: postgresadmin | ||
POSTGRES_PASSWORD: postgrespass | ||
POSTGRES_DB: pixel_identity_db | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Download and load docker image | ||
uses: ishworkh/docker-image-artifact-download@v1 | ||
with: | ||
image: "pixel-identity:local" | ||
- name: Launch docker image | ||
run: > | ||
docker run -d -p 44382:80 --network=${{ job.container.network }} | ||
-e AllowedOrigins=http://localhost:44382 -e IdentityHost=http://localhost:44382/pauth | ||
--env-file ./.config/identity-postgres-with-console-email.env | ||
--name pixel_identity_provider pixel-identity:local | ||
- name: Print container details | ||
run: docker container ls | ||
- name: Setup dotnet ${{ matrix.dotnet-version }} | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{ matrix.dotnet-version }} | ||
- name: Build test project | ||
run: dotnet build src/Pixel.Identity.UI.Tests/Pixel.Identity.UI.Tests.csproj | ||
- name: print container logs | ||
run: docker logs pixel_identity_provider | ||
- name: Install browsers | ||
run: pwsh src/Pixel.Identity.UI.Tests/bin/Debug/net6.0/playwright.ps1 install | ||
- name: Execute tests | ||
run: dotnet test --logger "trx;" src/Pixel.Identity.UI.Tests/Pixel.Identity.UI.Tests.csproj | ||
- name: Upload test results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pixel-identity-postgres-automation-test-results-${{ matrix.os }} | ||
path: src/Pixel.Identity.UI.Tests/TestResults | ||
|
||
|
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