feat: 🔐 add .env functionality #395
Workflow file for this run
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: good_food_frontend workflow | |
on: | |
push: | |
branches: | |
jobs: | |
check_codestyle: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: send start message | |
uses: appleboy/telegram-action@master | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
message: | | |
${{ github.workflow }} started! | |
Repository: ${{ github.repository }}. | |
Branch name: ${{ github.ref_name }}. | |
Commit author: ${{ github.actor }}. | |
Commit message: ${{ github.event.commits[0].message }}. | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18.x' | |
- name: Install and check codestyle | |
run: | | |
npm ci | |
npm run lint:js | |
npm run lint:styles | |
npm run lint:prettier | |
- name: send message | |
if: ${{ github.ref != 'refs/heads/main' }} | |
uses: appleboy/telegram-action@master | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
message: | | |
${{ github.workflow }} completed successfully! | |
Repository: ${{ github.repository }}. | |
Branch name: ${{ github.ref_name }}. | |
Commit author: ${{ github.actor }}. | |
Commit message: ${{ github.event.commits[0].message }}. | |
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} | |
build_and_push_to_docker_hub: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push frontend to Docker Hub | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/good_food_frontend:v.01 | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build_and_push_to_docker_hub | |
steps: | |
- name: executing remote ssh commands to deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_KEY }} | |
# passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
script: | | |
echo ${{ secrets.SSH_HOST_USER_PASSWORD }} | sudo -S docker compose stop | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/good_food_frontend:v.01 | |
sudo docker compose up -d | |
echo ${{ secrets.SSH_HOST_USER_PASSWORD }} | sudo -S docker image prune -f | |
send_message: | |
runs-on: ubuntu-latest | |
needs: deploy | |
steps: | |
- name: send message | |
uses: appleboy/telegram-action@master | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
message: | | |
${{ github.workflow }} completed successfully! | |
Repository: ${{ github.repository }}. | |
Branch name: ${{ github.ref_name }}. | |
Commit author: ${{ github.actor }}. | |
Commit message: ${{ github.event.commits[0].message }}. | |
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} |