chore: clean #1
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: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Install Docker Compose | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
- name: Log in to Docker Hub | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
- name: Set up environment variables | |
run: | | |
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> .env | |
echo "POSTGRES_HOST=${{ secrets.POSTGRES_HOST }}" >> .env | |
echo "POSTGRES_PORT=${{ secrets.POSTGRES_PORT }}" >> .env | |
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env | |
echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" >> .env | |
echo "API_KEY=${{ secrets.API_KEY }}" >> .env | |
echo "SCHEDULE_INTERVAL=${{ secrets.SCHEDULE_INTERVAL }}" >> .env | |
echo "REDIS_HOST=${{ secrets.REDIS_HOST }}" >> .env | |
echo "REDIS_PORT=${{ secrets.REDIS_PORT }}" >> .env | |
echo "SEED=${{ secrets.SEED }}" >> .env | |
- name: Build and push Docker images | |
run: | | |
docker-compose --env-file .env -f docker-compose.yaml build | |
docker-compose --env-file .env -f docker-compose.yaml push | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Kubernetes | |
uses: azure/setup-kubectl@v1 | |
with: | |
version: 'latest' | |
- name: Create .kube directory | |
run: mkdir -p ~/.kube | |
- name: Set up Kubeconfig | |
run: | | |
echo "${{ secrets.KUBE_CONFIG_DATA }}" | base64 --decode > ~/.kube/config | |
- name: Set up environment variables | |
run: | | |
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env | |
echo "API_KEY=${{ secrets.API_KEY }}" >> .env | |
- name: Give execute permissions to deploy.sh | |
run: chmod +x ./hack.sh | |
- name: Run deploy.sh script | |
run: ./hack.sh |