Skip to content

made changes to the CI #11

made changes to the CI

made changes to the CI #11

name: Publish Docker Image - Frontend
on:
push:
branches:
- integration
jobs:
ci-frontend:
name: Push frontend Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
env:
IMAGE_REGISTRY_BACKEND: ${{ vars.IMAGE_REGISTRY_BACKEND }}
IMAGE_REGISTRY_FRONTEND: ${{ vars.IMAGE_REGISTRY_FRONTEND }}
if: github.actor != 'github-actions[bot]'
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: create env file
run: |
cd application/frontend
echo ${{ secrets.VITE_API_URL }} > .env
- name: Generate docker image tag
run: echo "IMAGE_TAG=$GITHUB_SHA" >> $GITHUB_ENV && echo $IMAGE_TAG
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and upload Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: application/frontend
file: application/frontend/Dockerfile
push: true
tags: ${{ env.IMAGE_REGISTRY_FRONTEND }}:${{ env.IMAGE_TAG }}
- name: Edit compose file with new tag and push to repo
run: |
cd application
sed -i 's/monitoring-frontend-repo:.*/monitoring-frontend-repo:${{ env.IMAGE_TAG }}/g' compose.app.yaml
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff --cached --quiet || git commit -m "Auto update"
git push origin HEAD:integration
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ci-backend:
name: Push backend image to Dockerhub
runs-on: ubuntu-latest
needs: ci-frontend
permissions:
packages: write
contents: write
env:
IMAGE_REGISTRY_BACKEND: ${{ vars.IMAGE_REGISTRY_BACKEND }}
IMAGE_REGISTRY_FRONTEND: ${{ vars.IMAGE_REGISTRY_FRONTEND }}
if: github.actor != 'github-actions[bot]'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: create env file
run: |
cd application/backend
echo ${{ secrets.ENV_FILE }} > .env
- name: Generate docker image tag
run: echo "IMAGE_TAG=$GITHUB_SHA" >> $GITHUB_ENV && echo $IMAGE_TAG
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and upload Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: application/backend
file: application/backend/Dockerfile
push: true
tags: ${{ env.IMAGE_REGISTRY_BACKEND }}:${{ env.IMAGE_TAG }}
- name: Edit compose file with new tag and push to repo
run: |
cd application
sed -i 's/monitoring-backend-repo:.*/monitoring-backend-repo:${{ env.IMAGE_TAG }}/g' compose.app.yaml
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff --cached --quiet || git commit -m "Auto update"
git push origin HEAD:integration
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}