This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
WIP #11
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: CD(staging) | |
on: # 検証用。マージ時に修正する。 | |
push: | |
branches: | |
- feature/staging | |
workflow_dispatch: | |
jobs: | |
push-image: | |
runs-on: ubuntu-latest | |
environment: stg | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/twin-te/twinte-back | |
tags: stg | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: deploy.Dockerfile | |
push: true | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
deploy: | |
runs-on: ubuntu-latest | |
needs: push-image | |
environment: stg | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy to app server | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.APP_HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: ${{ secrets.PORT }} | |
script: ~/twinte-infra-v4/staging/app/scripts/deploy-back.sh | |
- name: Deploy to db server | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.DB_HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: ${{ secrets.PORT }} | |
script: ~/twinte-infra-v4/staging/db/scripts/deploy-back.sh |