hotfix: added RPC-secret to github workflow #104
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 | |
on: | |
push: | |
branches: | |
- production | |
pull_request: | |
branches: | |
- production | |
types: | |
- closed | |
jobs: | |
build_and_deploy: | |
runs-on: | |
labels: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Print important information | |
env: | |
CHICMOZ_AZTEC_RPC: ${{ env.CHICMOZ_AZTEC_RPC }} | |
run: | | |
echo "VERSION: $(git describe --tags)" | |
echo "CHICMOZ_AZTEC_RPC: $CHICMOZ_AZTEC_RPC" | |
shell: bash | |
- 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: Log in to DigitalOcean Container Registry with short-lived credentials | |
run: doctl registry login --expiry-seconds 1200 | |
- name: Cleanup old images | |
run: | | |
bash -x "scripts/production/cleanup-registry.sh" | |
- name: Save DigitalOcean kubeconfig | |
run: doctl kubernetes cluster kubeconfig save "chicmoz-prod" | |
- name: Deploy to cluster with Skaffold | |
env: | |
CHICMOZ_AZTEC_RPC: ${{ env.CHICMOZ_AZTEC_RPC }} | |
run: | | |
MAX_RETRIES=3 | |
RETRY_DELAY=10 | |
kubectl create secret generic global --from-literal=CHICMOZ_AZTEC_RPC=$CHICMOZ_AZTEC_RPC | |
for i in $(seq 1 $MAX_RETRIES); do | |
if bash -x scripts/production/deploy.sh; 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 |