Skip to content

Commit 5de3b8b

Browse files
Add workflows for PR validation (#14)
1 parent 9129a73 commit 5de3b8b

File tree

7 files changed

+496
-29
lines changed

7 files changed

+496
-29
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ RUN yay -Sy --noconfirm \
3434
azure-cli-bin \
3535
kubectl \
3636
nvm \
37-
pulumi
37+
pulumi \
38+
act
3839

3940
COPY .nvmrc .
4041
ENV NVM_DIR=/home/$USERNAME/.nvm

.devcontainer/devcontainer.json

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
{
2-
"name": "UnMango Wishlists",
3-
"dockerComposeFile": "docker-compose.yaml",
4-
"service": "devcontainer",
5-
"workspaceFolder": "/workspaces",
6-
"workspaceMount": "/workspaces",
7-
"customizations": {
8-
"vscode": {
9-
"extensions": [
10-
"ms-azuretools.vscode-docker",
11-
"dbaeumer.vscode-eslint",
12-
"esbenp.prettier-vscode",
13-
"graphql.vscode-graphql-syntax",
14-
"editorconfig.editorconfig",
15-
"ms-dotnettools.csharp"
16-
],
17-
"settings": {
18-
"terminal.integrated.defaultProfile.linux": "zsh",
19-
"terminal.integrated.profiles.linux": {
20-
"zsh": {
21-
"path": "zsh"
22-
}
23-
}
24-
}
25-
}
26-
}
2+
"name": "UnMango Wishlists",
3+
"dockerComposeFile": "docker-compose.yaml",
4+
"service": "devcontainer",
5+
"workspaceFolder": "/workspaces",
6+
"remoteUser": "vscode",
7+
"features": {
8+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
9+
},
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"ms-azuretools.vscode-docker",
14+
"dbaeumer.vscode-eslint",
15+
"esbenp.prettier-vscode",
16+
"graphql.vscode-graphql-syntax",
17+
"editorconfig.editorconfig",
18+
"ms-dotnettools.csharp"
19+
],
20+
"settings": {
21+
"terminal.integrated.defaultProfile.linux": "zsh",
22+
"terminal.integrated.profiles.linux": {
23+
"zsh": {
24+
"path": "zsh"
25+
}
26+
}
27+
}
28+
}
29+
}
2730
}

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ indent_style = tab # Accessibility
77

88
[*.{yml,yaml}]
99
indent_style = space
10+
indent_size = 2

.github/workflows/main.yaml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Main Workflow
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
api:
11+
runs-on: ubuntu-latest
12+
env:
13+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
14+
DOTNET_NOLOGO: true
15+
DOTNET_CLI_TELEMETRY_OPTOUT: true
16+
defaults:
17+
run:
18+
working-directory: api/UnMango.Wishlists.Api
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-dotnet@v3
23+
with:
24+
global-json-file: global.json
25+
cache: true
26+
cache-dependency-path: |
27+
api/UnMango.Wishlists.Api/packages.lock.json
28+
29+
- run: dotnet restore --locked-mode
30+
- run: dotnet build -c Release
31+
32+
web:
33+
runs-on: ubuntu-latest
34+
defaults:
35+
run:
36+
working-directory: app/web
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version-file: .nvmrc
43+
cache-dependency-path: |
44+
**/package-lock.json
45+
46+
- run: npm ci
47+
- run: npm run build
48+
49+
api-docker:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
57+
- name: Docker meta
58+
id: meta
59+
uses: docker/metadata-action@v5
60+
with:
61+
images: ghcr.io/${{ github.repository_owner }}/wishlists-api
62+
tags: |
63+
type=ref,event=branch
64+
type=ref,event=pr
65+
type=semver,pattern={{version}}
66+
type=semver,pattern={{major}}.{{minor}}
67+
type=semver,pattern={{major}}
68+
type=sha
69+
70+
- name: Login to GitHub Container Registry
71+
uses: docker/login-action@v3
72+
if: github.event_name != 'pull_request'
73+
with:
74+
registry: ghcr.io
75+
username: ${{ github.repository_owner }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Build and push
79+
uses: docker/build-push-action@v5
80+
with:
81+
context: api/UnMango.Wishlists.Api
82+
file: api/UnMango.Wishlists.Api/Dockerfile
83+
provenance: true
84+
platforms: linux/amd64,linux/arm64
85+
push: ${{ github.event_name != 'pull_request' }}
86+
tags: ${{ steps.meta.outputs.tags }}
87+
labels: ${{ steps.meta.outputs.labels }}
88+
89+
web-docker:
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v4
93+
94+
- name: Set up Docker Buildx
95+
uses: docker/setup-buildx-action@v3
96+
97+
- name: Docker meta
98+
id: meta
99+
uses: docker/metadata-action@v5
100+
with:
101+
images: ghcr.io/${{ github.repository_owner }}/wishlists-web
102+
tags: |
103+
type=ref,event=branch
104+
type=ref,event=pr
105+
type=semver,pattern={{version}}
106+
type=semver,pattern={{major}}.{{minor}}
107+
type=semver,pattern={{major}}
108+
type=sha
109+
110+
- name: Login to GitHub Container Registry
111+
uses: docker/login-action@v3
112+
if: github.event_name != 'pull_request'
113+
with:
114+
registry: ghcr.io
115+
username: ${{ github.repository_owner }}
116+
password: ${{ secrets.GITHUB_TOKEN }}
117+
118+
- name: Build and push
119+
uses: docker/build-push-action@v5
120+
with:
121+
context: app/web
122+
file: app/web/Dockerfile
123+
provenance: true
124+
platforms: linux/amd64,linux/arm64
125+
push: ${{ github.event_name != 'pull_request' }}
126+
tags: ${{ steps.meta.outputs.tags }}
127+
labels: ${{ steps.meta.outputs.labels }}

api/UnMango.Wishlists.Api/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0 as build
1+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 as build
2+
ARG TARGETARCH
23

34
WORKDIR /build
45
COPY *.csproj .
5-
RUN dotnet restore
6+
COPY *packages.lock.json .
7+
RUN dotnet restore -a $TARGETARCH
68

79
COPY ./ .
8-
RUN dotnet publish -c Release -o /out
10+
RUN dotnet publish --no-restore -c Release -a $TARGETARCH -o /out
911

1012
FROM mcr.microsoft.com/dotnet/aspnet:8.0
1113
WORKDIR /app

api/UnMango.Wishlists.Api/UnMango.Wishlists.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
78
</PropertyGroup>
89

910
<ItemGroup>

0 commit comments

Comments
 (0)