Skip to content

Update README.md

Update README.md #3

Workflow file for this run

name: Elixir CI
on:
push:
tags:
- "*"
branches:
- "main"
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
services:
db:
image: postgres:17
ports: ["5432:5432"]
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
name: Build and test
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
with:
elixir-version: "1.15.2" # [Required] Define the Elixir version
otp-version: "26.0" # [Required] Define the Erlang/OTP version
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Compile the project
run: mix compile
- name: Run tests
run: mix test
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Start EC2 instance
run: curl -X GET ${{ secrets.API_POINT }}
- name: Install Python
if: startsWith(github.ref, 'refs/tags/')
uses: actions/setup-python@v4
with:
python-version: "3.11"
architecture: "x64"
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-ansible
- name: Install Ansible
run: |
python -m pip install --user ansible
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Create SSH key file
run: echo "${{ secrets.KEY }}" | tr -d '\r' > key.pem
- name: Set permissions for SSH key
run: chmod 600 key.pem
- name: Create Ansible inventory file
run: echo -e "[EC2]\n${{ secrets.HOSTS }}" > inventory.ini
- name: Display Ansible inventory file
run: cat inventory.ini
- name: Wait for SSH to be available
run: |
for i in {1..30}; do
ssh -o StrictHostKeyChecking=no -i key.pem ec2-user@${{ secrets.HOSTS }} 'echo SSH is available' && break
echo "Waiting for SSH to be available..."
sleep 10
done
- name: Run Ansible Playbook
run: |
ansible-playbook Playbook.yml -i inventory.ini --private-key key.pem --ssh-extra-args "-o StrictHostKeyChecking=no" --extra-vars "POSTGRES_USER=${{ secrets.POSTGRES_USER }} POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} POSTGRES_DB=${{ secrets.POSTGRES_DB }} DATABASE_HOSTNAME=${{ secrets.DATABASE_HOSTNAME }} PGADMIN_DEFAULT_EMAIL=${{ secrets.PGADMIN_DEFAULT_EMAIL }} PGADMIN_DEFAULT_PASSWORD=${{ secrets.PGADMIN_DEFAULT_PASSWORD }} FRONTEND_DNS=${{ secrets.FRONTEND_DNS }} BACKEND_DNS=${{ secrets.BACKEND_DNS }} PGADMIN_DNS=${{ secrets.PGADMIN_DNS }} kuramacert=${{ secrets.kuramacert }} kuramakey=${{ secrets.kuramakey }} CLIENT_ID_GOOGLE=${{ secrets.CLIENT_ID_GOOGLE }} CLIENT_SECRET_GOOGLE=${{ secrets.CLIENT_SECRET_GOOGLE }}"
mail:
name: Send mail
needs: deploy
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Read and filter email content
id: read_email_content
run: |
content=$(sed '/^---$/d;/^title:/d;/^description:/d' frontend/src/content/release-${{ github.ref_name }}.md)
echo "content<<EOF" >> $GITHUB_ENV
echo "$content" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Send mail
uses: dawidd6/action-send-mail@v2
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.SMTP_USER }}
password: ${{ secrets.SMTP_PASSWORD }}
subject: Time manager release ${{ github.ref_name }}
convert_markdown: true
body: ${{ env.content }}
to: [email protected], [email protected]
from: Batman
content_type: text/html