Skip to content

Commit

Permalink
testing github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kishanhathiwalaCS committed Mar 17, 2023
1 parent 1eddac4 commit 5d1aec5
Show file tree
Hide file tree
Showing 146 changed files with 75,195 additions and 12,376 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
96 changes: 60 additions & 36 deletions .github/workflows/main.yml
Expand Up @@ -2,41 +2,65 @@ name: learn-github-actions
run-name: ${{ github.actor }} is learning Github Actions
on: [push]
jobs:
check-bats-version:
runs-on: ubuntu-latest
steps:
- name: Prepare python
uses: actions/setup-python@v4.5.0
with:
python-version: 3.11.0
setup-job:
name: Checkout repo
runs-on: ubuntu-latest
outputs:
application_name: ${{ steps.set-env.outputs.appname }}
steps:
- name: Code checkout
uses: actions/checkout@v2

- name: Set env
id: set-env
run: |
echo "appname=$APP_NAME" >> $GITHUB_OUTPUT
build-docker-image:
name: Build and push docker image
needs: [setup-job]
runs-on: ubuntu-latest
steps:
- name: Build image
run: |
docker build * -f Dockerfile --tag webapplication2 .
pacttest-uploader:
runs-on: ubuntu-latest
needs: [setup-job, build-docker-image]
steps:
- name: Prepare python
uses: actions/setup-python@v4.5.0
with:
python-version: 3.11.0

- name: run id
run: echo ${{ github.run_id }}
- name: run number
run: echo ${{ github.run_number }}
- name: Setup docker container
id: setup-container
run: |
container_id=`docker create `${{ needs.build-docker-image.outputs.published_image_path }}`
if [$?=0]; then
mkdir -p files
docker cp $container_id:/app/pacts files
docker rm $container_id
ls -alhR files
else
echo "Unable to run the image: ${{ needs.build-docker-image.outputs.published_image_path }}"
exit 1
fi
echo "containerId=$container_id" >> $GITHUB_OUTPUT
- name: Prepare python script
id: python-script
run: |
PYTHON_SCRIPT=$(cat <<EOF
import json, urllib.request
with open('/mnt/c/Kishan/repos/csn.showroom.cms.api/ConsumerPact.Tests/bin/Debug/pacts/Csn.Showroom.CMS.Api-Csn.Showroom.Spec.Api.json') as json_data:
pact = json.load(json_data)
pact_url = 'http://pact-broker.stg.commercial.csnglobal.net/pacts/provider/{}/consumer/{}/version/{}'.format(pact['provider']['name'],pact['consumer']['name'], 1)
opener = urllib.request.build_opener(urllib.request.HTTPHandler)
request = urllib.request.Request(pact_url, data=json.dumps(pact).encode('utf-8'))
request.add_header('Content-Type', 'application/json')
request.add_header('Authorization','Basic dXfltyFMgNOFZAxr8io9wJ37iUpY42M:O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1')
request.get_method = lambda: 'PUT'
print(pact_url)
url = opener.open(request, timeout = 10)
response = url.read()
print(response)
EOF
)
python -c "$PYTHON_SCRIPT"
check-node-version:
runs-on: ubuntu-latest
steps:
- run: npm -v
- name: Prepare python script
id: python-script
run: |
PYTHON_SCRIPT=$(cat <<EOF
import glob, os json, urllib.request
version = ${{ github.run_id }}
os.chdir('files')
for f in glob.glob('*.json'):
with open(f) as json_data:
pact = json.load(json_data)
pact_url = 'http://pact-broker.stg.commercial.csnglobal.net/pacts/provider/{}/consumer/{}/version/{}'.format(pact['provider']['name'],pact['consumer']['name'], 1)
print(response)
EOF
)
python -c "$PYTHON_SCRIPT"
22 changes: 22 additions & 0 deletions Dockerfile
@@ -0,0 +1,22 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["WebApplication2/WebApplication2.csproj", "WebApplication2/"]
RUN dotnet restore "WebApplication2/WebApplication2.csproj"
COPY . .
WORKDIR "/src/WebApplication2"
RUN dotnet build "WebApplication2.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "WebApplication2.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApplication2.dll"]
22 changes: 15 additions & 7 deletions WebApplication2.sln
@@ -1,20 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
# Visual Studio Version 17
VisualStudioVersion = 17.6.33417.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication2", "WebApplication2\WebApplication2.csproj", "{3401624B-BF1C-43C4-99F3-78F28629C8E2}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5E46272E-727E-4F3C-85EA-14E8C3D56FDA}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
.gitattributes = .gitattributes
.gitignore = .gitignore
Dockerfile = Dockerfile
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication2", "WebApplication2\WebApplication2.csproj", "{0653093B-E8E5-4597-842E-3FEA3E5F1E77}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3401624B-BF1C-43C4-99F3-78F28629C8E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3401624B-BF1C-43C4-99F3-78F28629C8E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3401624B-BF1C-43C4-99F3-78F28629C8E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3401624B-BF1C-43C4-99F3-78F28629C8E2}.Release|Any CPU.Build.0 = Release|Any CPU
{0653093B-E8E5-4597-842E-3FEA3E5F1E77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0653093B-E8E5-4597-842E-3FEA3E5F1E77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0653093B-E8E5-4597-842E-3FEA3E5F1E77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0653093B-E8E5-4597-842E-3FEA3E5F1E77}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 5d1aec5

Please sign in to comment.