Merge pull request #390 from shunny822/be/test/users-e2e #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: develop CD | |
on: | |
push: | |
branches: [ develop ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code. | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: '20.x' | |
- name: Install yarn | |
run: npm install -g yarn | |
- name: Build with yarn | |
run: | | |
yarn install | |
yarn workspace frontend build | |
yarn workspace backend build | |
- name: make BE .env | |
run: | | |
echo "${{ secrets.BE_ENV }}" > .env | |
- name: send BE .env | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
source: .env | |
target: /dandi | |
overwrite: true | |
- name: make FE .env | |
run: | | |
cd frontend | |
echo "${{ secrets.FE_ENV }}" > .env | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: make docker images | |
run: | | |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-be:${{ github.sha }} -f ./Dockerfile.was . | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-be:${{ github.sha }} | |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-fe:${{ github.sha }} -f ./Dockerfile.front . | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-fe:${{ github.sha }} | |
- name: make docker-compose files | |
run: | | |
sed -i "s/GITHUB_SHA/${{ github.sha }}/g" ./docker/docker-compose.blue.yml | |
sed -i "s/GITHUB_SHA/${{ github.sha }}/g" ./docker/docker-compose.green.yml | |
- name: send files & deploy script | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
source: "nginx/dandi-blue.conf,nginx/dandi-green.conf,docker/docker-compose.blue.yml,docker/docker-compose.green.yml,docker/deploy.sh" | |
target: /dandi | |
overwrite: true | |
- name: deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-be:${{ github.sha }} | |
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/dandi-fe:${{ github.sha }} | |
cd /dandi/docker | |
chmod +x deploy.sh | |
./deploy.sh |