add env variable #23
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: CI/CD Chicmoz Prod | |
# TODO | |
on: | |
push: | |
branches: | |
- "devops/create-develop-skaffold" | |
pull_request: | |
branches: | |
- production | |
types: | |
- closed | |
env: | |
DOCKER_CONFIG: ${{ github.workspace }}/.docker | |
jobs: | |
build_and_deploy: | |
runs-on: | |
labels: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Install Skaffold | |
run: | | |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 | |
sudo install skaffold /usr/local/bin/ | |
shell: bash | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- name: Set up Docker authentication | |
run: | | |
mkdir -p ${{ env.DOCKER_CONFIG }} | |
docker login registry.digitalocean.com -u ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} --password-stdin <<< "${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}" | |
- name: Cleanup old images | |
run: | | |
chmod +x ".github/workflows/cleanup-script.sh" | |
bash -x ".github/workflows/cleanup-script.sh" | |
- name: Save DigitalOcean kubeconfig | |
run: doctl kubernetes cluster kubeconfig save "chicmoz-prod" | |
- name: Deploy to cluster with Skaffold | |
run: | | |
MAX_RETRIES=3 | |
RETRY_DELAY=10 | |
for i in $(seq 1 $MAX_RETRIES); do | |
if skaffold run --filename "k8s/production/skaffold.production.yaml" --default-repo=registry.digitalocean.com/aztlan-containers; then | |
echo "Deployment successful" | |
exit 0 | |
fi | |
echo "Attempt $i failed. Retrying in $RETRY_DELAY seconds..." | |
sleep $RETRY_DELAY | |
done | |
echo "Deployment failed after $MAX_RETRIES attempts" | |
exit 1 |