-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (41 loc) · 1.61 KB
/
dotnet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: CI/CD Pipeline
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x' # Adjust the .NET version as necessary
- name: Restore dependencies
run: dotnet restore src/src.sln
- name: Build project
run: dotnet build src/src.sln --configuration Release
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/webapiargocd:latest -f src/Dockerfile .
- name: Log in to Docker Hub
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Push Docker image
run: docker push ${{ secrets.DOCKER_USERNAME }}/webapiargocd:latest
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout manifests repository
uses: actions/checkout@v4
with:
repository: ryzam/k8s-manifests-repo
ssh-key: ${{ secrets.REPO_SSH_PRIVATE_KEY }}
- name: Update Kubernetes manifests
run: |
sed -i 's|image: .*$|image: ${{ secrets.DOCKER_USERNAME }}/webapiargocd:latest|' k8/deployment.yaml
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add k8/deployment.yaml
git commit -m "Update image to ${{ secrets.DOCKER_USERNAME }}/webapiargocd:latest"
git push origin main
- name: Print message
run: echo "Hello, this is a simple GitHub Action!"