Skip to content
name: Github Actions for building and pushing docker
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create file after checkout
working-directory: ./backend
run: |
sed -i '/PORT=/c\PORT=${{ secrets.MONGO_PORT }}' .env
sed -i '/MONGO_USER=/c\MONGO_USER=${{ secrets.MONGO_USER }}' .env
sed -i '/MONGO_PASS=/c\MONGO_PASS=${{ secrets.MONGO_PASS }}' .env
sed -i '/MONGO_API=/c\MONGO_API=${{ secrets.MONGO_API }}' .env
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
context: ./backend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/node-server:0.0.${{ github.run_number }}.RELEASE
- name: Create file for Front-end
working-directory: ./frontend
run: |
sed -i '/PORT=/c\PORT=${{ secrets.REACT_APP_PORT }}' .env
- uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/react-app:0.0.${{ github.run_number }}.RELEASE
- uses: actions/checkout@v4
with:
repository: 'famasboy888/CICD_ArgoCD_States'
path: 'MERN_helm-chart'
token: ${{ secrets.GIT_TOKEN }}
persist-credentials: true
- name: check files
shell: bash
working-directory: MERN_helm-chart
run: |
ls *
echo 'versionNumber: ${{ github.run_number }}' > MERN_helm-chart/values.yaml
git config user.name famasboy888
git config user.email famasboy88@gmail.com
git add .
git commit -m 'Pushed from GitHub Actions front end. Build number: ${{ github.run_number }}'
git push