Skip to content

Merge pull request #452 from dump-hr/update-2024-env #215

Merge pull request #452 from dump-hr/update-2024-env

Merge pull request #452 from dump-hr/update-2024-env #215

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
- '2024'
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 frontend web apps
run: yarn build --filter=admin... --filter=sponsor... --filter=web... --filter=app...
- 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 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 }},
ghcr.io/${{ github.repository }}:${{ 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/[email protected]
- name: Login to AWS
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} --profile ddays-app
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} --profile ddays-app
- name: Run Ansible playbook
run: |
eval $(ssh-agent)
./infrastructure/scripts/ansible-playbook.sh ${{ github.ref_name == 'main' && 'production' || github.ref_name }} api