🚀release-billing-server-dev@feature/payments #18
Workflow file for this run
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: 🚀release-billing-server | |
run-name: 🚀release-billing-server-${{ github.event.inputs.build_type}}@${{ github.ref_name }} | |
on: | |
workflow_dispatch: | |
inputs: | |
build_type: | |
type: choice | |
description: Select the type of build | |
options: | |
- dev | |
- prod | |
jobs: | |
input-validation: | |
runs-on: ubuntu-latest | |
steps: | |
- id: input-validation | |
name: input validation | |
run: | | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' | |
build_type=${{ github.event.inputs.build_type }} | |
if [ "$build_type" = "dev" ]; then | |
echo "build_type is dev" | |
elif [ "$build_type" = "prod" ]; then | |
echo "build_type is prod" | |
else | |
echo -e "${RED}build_type is not valid${NC}" | |
exit 1 | |
fi | |
build-billing-server: | |
runs-on: ubuntu-latest | |
needs: input-validation | |
steps: | |
- name: docker init | |
run: docker system prune --volumes -a -f | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: DEV Configure AWS credentials | |
if: github.event.inputs.build_type == 'dev' | |
uses: aws-actions/configure-aws-credentials@v1-node16 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_DEV_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_DEV_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: PROD Configure AWS credentials | |
if: github.event.inputs.build_type == 'prod' | |
uses: aws-actions/configure-aws-credentials@v1-node16 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR Private | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
context: . | |
tags: ${{ steps.login-ecr.outputs.registry }}/${{ github.event.inputs.build_type }}-billing-server:latest | |
platforms: linux/x86_64 | |
target: billing-server | |
file: dockerfile.billing | |
release-billing-server: | |
runs-on: ${{ github.event.inputs.build_type }}-billing-server | |
needs: [input-validation, build-billing-server] | |
# needs: [input-validation] | |
steps: | |
- name: Checkout | |
uses: Bhacaz/checkout-files@v2 | |
with: | |
files: docker-compose-billing.yml | |
- name: DEV Configure AWS credentials | |
if: github.event.inputs.build_type == 'dev' | |
uses: aws-actions/configure-aws-credentials@v1-node16 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_DEV_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_DEV_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: PROD Configure AWS credentials | |
if: github.event.inputs.build_type == 'prod' | |
uses: aws-actions/configure-aws-credentials@v1-node16 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Login to Amazon ECR Private | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: docker init | |
run: docker system prune --volumes -a -f | |
- name: DEV set .env | |
if: github.event.inputs.build_type== 'dev' | |
run: | | |
sed -i "s|DOGU_BILLING_RUN_TYPE=.*$|DOGU_BILLING_RUN_TYPE=development|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_BILLING_DB_URL=.*$|DOGU_BILLING_DB_URL=${{secrets.DEV_DOGU_BILLING_DB_URL }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_BILLING_DB_SSL_CONNECTION=.*$|DOGU_BILLING_DB_SSL_CONNECTION=${{secrets.DEV_DOGU_BILLING_DB_SSL_CONNECTION }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_CONSOLE_DB_READ_URL=.*$|DOGU_CONSOLE_DB_READ_URL=${{secrets.DEV_DOGU_CONSOLE_DB_READ_URL }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_BILLING_NICE_CLIENT_KEY=.*$|DOGU_BILLING_NICE_CLIENT_KEY=${{secrets.DEV_DOGU_BILLING_NICE_CLIENT_KEY }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_BILLING_NICE_SECRET_KEY=.*$|DOGU_BILLING_NICE_SECRET_KEY=${{secrets.DEV_DOGU_BILLING_NICE_SECRET_KEY }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_EMAIL_ID=.*$|DOGU_EMAIL_ID=${{secrets.DOGU_EMAIL_ID }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_EMAIL_PW=.*$|DOGU_EMAIL_PW=${{secrets.DOGU_EMAIL_PW }}|" ./docker-compose-billing.yml | |
- name: PROD set .env | |
if: github.event.inputs.build_type == 'prod' | |
run: | | |
sed -i "s|DOGU_BILLING_RUN_TYPE=.*$|DOGU_BILLING_RUN_TYPE=production|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_BILLING_DB_URL=.*$|DOGU_BILLING_DB_URL=${{secrets.PROD_DOGU_BILLING_DB_URL }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_BILLING_DB_SSL_CONNECTION=.*$|DOGU_BILLING_DB_SSL_CONNECTION=${{secrets.PROD_DOGU_BILLING_DB_SSL_CONNECTION }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_CONSOLE_DB_READ_URL=.*$|DOGU_CONSOLE_DB_READ_URL=${{secrets.PROD_DOGU_CONSOLE_DB_READ_URL }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_BILLING_NICE_CLIENT_KEY=.*$|DOGU_BILLING_NICE_CLIENT_KEY=${{secrets.PROD_DOGU_BILLING_NICE_CLIENT_KEY }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_BILLING_NICE_SECRET_KEY=.*$|DOGU_BILLING_NICE_SECRET_KEY=${{secrets.PROD_DOGU_BILLING_NICE_SECRET_KEY }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_EMAIL_ID=.*$|DOGU_EMAIL_ID=${{secrets.DOGU_EMAIL_ID }}|" ./docker-compose-billing.yml | |
sed -i "s|DOGU_EMAIL_PW=.*$|DOGU_EMAIL_PW=${{secrets.DOGU_EMAIL_PW }}|" ./docker-compose-billing.yml | |
- name: run | |
run: | | |
docker ps -qa | xargs -r docker rm -f | |
docker compose -f docker-compose-billing.yml pull ${{ github.event.inputs.build_type }}-billing-server | |
docker compose -f ./docker-compose-billing.yml --verbose up -d ${{ github.event.inputs.build_type }}-billing-server | |
send-slack: | |
runs-on: ubuntu-latest | |
needs: release-billing-server | |
if: ${{ always() }} | |
steps: | |
- name: Send Slack | |
uses: dogu-team/[email protected] | |
with: | |
template: 'CD' | |
slack-channel-id: 'C057ML9UH34' | |
result-status: ${{ needs.release-billing-server.result }} | |
ignore-notify: false | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |