Skip to content

Production πŸš€ #92

Production πŸš€

Production πŸš€ #92

Workflow file for this run

name: Production πŸš€
on:
workflow_dispatch:
jobs:
inspection:
name: Run inspection πŸ§ͺ
runs-on: ubuntu-latest
steps:
- name: Use Node.js 21.5.0
uses: actions/setup-node@v3
with:
node-version: '21.5.0'
- name: Checkout repository πŸ”Ž
uses: actions/checkout@v3
- name: Install dependencies πŸ“¦
run: yarn install
- name: Lint code ✍️️
run: yarn lint
- name: Run tests βœ…
run: yarn test
build:
name: Build and publish image πŸ› οΈ
runs-on: ubuntu-latest
steps:
- name: Checkout repository πŸ”Ž
uses: actions/checkout@v3
- name: Build Docker image 🐳
run: |
docker build -f docker/production/Dockerfile . --tag ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_PROD_IMAGE_NAME }}:latest
- name: Publish Docker image πŸ“¦
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_PROD_IMAGE_NAME }}
deploy:
needs: build
name: Deploy image πŸš€
runs-on: ubuntu-latest
steps:
- name: Create ssh keys πŸ”‘
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSHKEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.HOST }} > ~/.ssh/known_hosts
- name: Pull and run container πŸƒοΈ
run: ssh ${{ secrets.USERNAME }}@${{ secrets.HOST }} "cd prod-minddaily && docker image prune -f && docker image prune -a && docker compose pull && docker compose up -d && exit"
- name: Cleanup 🧹
run: rm -rf ~/.ssh