update-submodules #297
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |