Skip to content

[feature] install blazer #817

[feature] install blazer

[feature] install blazer #817

Workflow file for this run

name: Deploy with Capistrano
on:
push:
branches: [ rc, master, main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs:
github_envs: ${{ steps.branch_check.outputs.github_envs }}
deploy_env: ${{ steps.branch_check.outputs.deploy_env }}
steps:
- name: Choose Environment
id: branch_check
run: |
echo "Running on branch ${{ github.ref }}"
if [ "${{ github.ref }}" = "refs/heads/master" ] || [ "${{ github.ref }}" = "refs/heads/main" ]; then
ENV_ARRAY="${{secrets.CLIENT_ENVS}}"
ENV_ARRAY="${ENV_ARRAY//, /,}"
ENV_ARRAY="${ENV_ARRAY//,/\",\"}"
echo "github_envs={\"value\":[\"${ENV_ARRAY}\"]}" >> $GITHUB_OUTPUT
echo "deploy_env=production" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" = "refs/heads/rc" ]; then
echo "github_envs={\"value\":['staging']}" >> $GITHUB_OUTPUT
echo "deploy_env=staging" >> $GITHUB_OUTPUT
fi
deploy:
needs: build
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJSON(needs.build.outputs.github_envs)}}
fail-fast: false
environment:
name: ${{ matrix.value }}
env:
SERVER_IP: ${{ secrets.SERVER_IP }}
BRANCH: ${{ secrets.BRANCH }}
steps:
- uses: actions/checkout@v3
- name: Install Rbenv
run: |
sudo git clone https://github.com/rbenv/rbenv.git /home/runner/.rbenv
sudo apt-get update
sudo apt-get install -y libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev
sudo git clone https://github.com/rbenv/ruby-build.git /home/runner/.rbenv/plugins/ruby-build
sudo chown -R runner /home/runner/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $GITHUB_PATH
source $GITHUB_PATH
eval "$(rbenv init -)"
rbenv install -s `cat .ruby-version`
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.6
bundler-cache: true
- uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Add public IP to AWS security group
uses: sohelamin/aws-security-group-add-ip-action@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
aws-security-group-id: ${{ secrets.AWS_SECURITY_GROUP_ID }}
port: '22'
to-port: '30'
protocol: 'tcp'
description: 'GitHub Action'
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- uses: miloserdow/capistrano-deploy@master
with:
target: ${{ needs.build.outputs.deploy_env }} # Defines the environment that will be used for the deployment
enc_rsa_key_val: ${{ secrets.DEPLOY_ID_RSA_ENC }}
deploy_key: ${{ secrets.DEPLOY_ENC_KEY }}