-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (80 loc) · 3.02 KB
/
update-submodules.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
name: "Update submodules"
on:
repository_dispatch:
types: [update-submodules]
workflow_dispatch:
jobs:
build-and-push-migrations:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GREEN_ECOLUTION_PAT }}
submodules: "true"
- name: Update submodules
env:
GITHUB_TOKEN: ${{ secrets.GREEN_ECOLUTION_PAT }}
run: git submodule update --init --recursive --remote -f
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push postgres migrations
uses: docker/build-push-action@v5
with:
context: .
token: ${{ secrets.GREEN_ECOLUTION_PAT }}
file: ./.docker/migrations/Dockerfile.postgres
platforms: linux/amd64
push: true
tags: ghcr.io/green-ecolution/migrations-postgres:latest
update-submodules:
needs: build-and-push-migrations
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GREEN_ECOLUTION_PAT }}
submodules: "recursive"
- name: Setup kube tools
uses: yokawasa/action-setup-kube-tools@v0.11.1
with:
setup-tools: |
kustomize
kustomize: "5.4.3"
- name: Initialize mandatory git config
run: |
git config user.name "GitHub Actions"
git config user.email noreply@github.com
- name: Update submodules
env:
GITHUB_TOKEN: ${{ secrets.GREEN_ECOLUTION_PAT }}
run: git submodule update --init --recursive --remote -f
- name: Get the latest commit hashes
run: |
COMMIT_SHA_BACKEND=$(cd green-ecolution-backend && git rev-parse --short HEAD)
COMMIT_SHA_FRONTEND=$(cd green-ecolution-frontend && git rev-parse --short HEAD)
echo "COMMIT_SHA_BACKEND=$COMMIT_SHA_BACKEND" >> $GITHUB_ENV
echo "COMMIT_SHA_FRONTEND=$COMMIT_SHA_FRONTEND" >> $GITHUB_ENV
- name: Dump frontend image tag
run: |
cd ./deploy/kustomize/dev
kustomize edit set image frontend-image=ghcr.io/green-ecolution/green-ecolution-frontend-dev:$COMMIT_SHA_FRONTEND
- name: Dump backend image tag
run: |
cd ./deploy/kustomize/dev
kustomize edit set image backend-image=ghcr.io/green-ecolution/green-ecolution-backend-dev:$COMMIT_SHA_BACKEND
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GREEN_ECOLUTION_PAT }}
run: |
git add green-ecolution-frontend green-ecolution-backend deploy/kustomize/dev/kustomization.yaml
git commit -m "chore: update submodules and dump image tag" && git push origin develop || echo "No changes to commit"