Merge pull request #148 from Kyutech-C3/develop #60
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" | |
jobs: | |
deploy: | |
name: deploy_to_takowasa | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: create asset folder | |
run: mkdir -p assets | |
- name: create .env file | |
run: | | |
touch .env | |
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> .env | |
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env | |
echo "POSTGRES_HOST=${{ secrets.POSTGRES_HOST }}" >> .env | |
echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" >> .env | |
echo "TZ=Asia/Tokyo" >> .env | |
echo "DISCORD_CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }}" >> .env | |
echo "DISCORD_CLIENT_SECRET=${{ secrets.DISCORD_CLIENT_SECRET }}" >> .env | |
echo "DISCORD_GUILD_ID=${{ secrets.DISCORD_GUILD_ID }}" >> .env | |
echo "TOKEN_SECRET_KEY=${{ secrets.TOKEN_SECRET_KEY }}" >> .env | |
echo "DISCORD_WEBHOOK_URL=${{ secrets.DISCORD_WEBHOOK_URL }}" >> .env | |
echo "HOST_URL=${{ secrets.HOST_URL }}" >> .env | |
echo "FRONTEND_HOST_URL=${{ secrets.FRONTEND_HOST_URL }}" >> .env | |
echo "ALLOW_ORIGIN_URLS=${{ secrets.ALLOW_ORIGIN_URLS }}" >> .env | |
echo "S3_BUCKET=${{ secrets.S3_BUCKET }}" >> .env | |
echo "S3_DIR=${{ secrets.S3_DIR }}" >> .env | |
echo "REGION_NAME=${{ secrets.REGION_NAME }}" >> .env | |
echo "ACCESS_KEY=${{ secrets.ACCESS_KEY }}" >> .env | |
echo "SECRET_ACCESS_KEY=${{ secrets.SECRET_ACCESS_KEY }}" >> .env | |
- name: create ssh config file | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
name: id_takowasa | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
config: | | |
Host takowasa | |
HostName 160.251.82.37 | |
User root | |
Port 13724 | |
IdentityFile ~/.ssh/id_takowasa | |
- name: deploy | |
run: | | |
rsync -av ./ takowasa:/opt/toybox-server | |
ssh takowasa "cd /opt/toybox-server; docker compose build; docker compose down; docker compose up -d" | |
- name: migrate | |
run: | | |
ssh takowasa "cd /opt/toybox-server; docker compose exec -T api pipenv run alembic upgrade head" |