-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (88 loc) · 3.44 KB
/
release.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Release
on:
workflow_dispatch:
jobs:
create-new-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Bump and Commit
run: |
npx standard-version
git push --follow-tags
push:
needs: create-new-release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
environment: docker
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
# Get version from package.json
- name: Get version from package.json
id: version
run: echo "version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
# Build the Docker image
- name: Build Docker image
run: docker build --cache-from democracy/democracy-server:latest -t democracy/democracy-server:${{ steps.version.outputs.version }} .
# Push the image to Docker Hub
- name: Push image to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push to Docker Hub
run: |
docker tag democracy/democracy-server:${{ steps.version.outputs.version }} democracy/democracy-server:latest
docker push democracy/democracy-server:latest
docker push democracy/democracy-server:${{ steps.version.outputs.version }}
create-pull-request-to-infrastructure:
needs: push
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository where the pull request should be created
- name: Checkout target repository
uses: actions/checkout@v3
with:
repository: demokratie-live/infrastructure
token: ${{ secrets.ACTION_INFRASTRUCTURE_PR }}
fetch-depth: 0
ref: main
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Step 2: Create a new Branch
- name: Create a new branch
run: |
git checkout -b democracy-server-${{ needs.push.outputs.version }}
git push --set-upstream origin democracy-server-${{ needs.push.outputs.version }}
- name: Edit file
run: |
sed -i -E "s/image: democracy\/democracy-server:.*$/image: democracy\/democracy-server:${{ needs.push.outputs.version }}/g" kustomize/base/main/democracy-api-depl.yaml
git add kustomize/base/main/democracy-api-depl.yaml
git commit -m "chore(infrastructure): update Docker container version in Kubernetes YAML"
git push --set-upstream origin democracy-server-${{ needs.push.outputs.version }}
# Step 4: Create the pull request
- name: Create Pull Request
uses: octokit/[email protected]
with:
route: POST /repos/{owner}/{repo}/pulls
owner: 'demokratie-live'
repo: infrastructure
title: 'New version for democracy-server ${{ needs.push.outputs.version }}'
base: main
head: democracy-server-${{ needs.push.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.ACTION_INFRASTRUCTURE_PR }}