fix build #85
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
docker_image_build: | |
name: Docker image build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Build web app | |
run: yarn turbo run build --filter=web... | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push api docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./apps/api/Dockerfile | |
push: true | |
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}, | |
ghcr.io/${{ github.repository }}:${{ github.ref_name == 'main' && 'latest' || 'unstable' }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Build and push code-runner docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./apps/code-runner/Dockerfile | |
push: true | |
tags: ghcr.io/dump-hr/code-runner:${{ github.sha }}, | |
ghcr.io/dump-hr/code-runner:${{ github.ref_name == 'main' && 'latest' || 'unstable' }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
ansible_playbook: | |
name: Run Ansible playbook | |
runs-on: ubuntu-latest | |
needs: | |
- docker_image_build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
cache-dependency-path: './infrastructure/ansible/requirements.txt' | |
- name: Install Ansible | |
run: | | |
pip install -r ./infrastructure/ansible/requirements.txt | |
- name: Install Ansible dependencies | |
run: | | |
ansible-galaxy install -r ./infrastructure/ansible/requirements.yml | |
- name: Setup sops | |
uses: mdgreenwald/mozilla-sops-action@v1.4.1 | |
- name: Login to AWS | |
run: | | |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --profile internship-app | |
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --profile internship-app | |
- name: Run Ansible playbook | |
run: | | |
eval $(ssh-agent) | |
./infrastructure/scripts/ansible-playbook.sh production api |