Correct set-env-vars flag placement #11
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: 'Continuous Delivery' | |
on: | |
push: | |
branches: | |
- main | |
- release/* | |
- feature/* | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SA_KEY }} | |
GCS_BUCKET: ${{ secrets.GCS_BUCKET }} | |
APP_NAME: 'flight-delay-api' | |
REGION: 'us-central1' | |
outputs: | |
url: ${{ steps.deploy.outputs.url }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Print environment variables (debugging) | |
run: | | |
echo "PROJECT_ID=${{ env.PROJECT_ID }}" | |
echo "SERVICE_ACCOUNT_KEY=${{ env.SERVICE_ACCOUNT_KEY }}" | head -c 20 | |
echo "GCS_BUCKET=${{ env.GCS_BUCKET }}" | |
- name: Set up Google Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
service_account_key: ${{ env.SERVICE_ACCOUNT_KEY }} | |
project_id: ${{ env.PROJECT_ID }} | |
export_default_credentials: true | |
- name: Configure Docker to use the gcloud command-line tool as a credential helper | |
run: gcloud auth configure-docker | |
- name: Build Docker image | |
run: | | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.APP_NAME }} . --platform linux/amd64 | |
- name: Push Docker image | |
run: | | |
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.APP_NAME }} | |
- name: Deploy to Cloud Run | |
id: deploy | |
run: | | |
echo "Deploying to Cloud Run" | |
URL=$(gcloud run deploy ${{ env.APP_NAME }} \ | |
--image gcr.io/${{ env.PROJECT_ID }}/${{ env.APP_NAME }} \ | |
--platform managed \ | |
--region ${{ env.REGION }} \ | |
--allow-unauthenticated \ | |
--set-env-vars GCS_BUCKET=${{ secrets.GCS_BUCKET }}\ | |
--format 'value(status.url)') | |
echo "url=$URL" >> $GITHUB_OUTPUT | |
echo "Deployed to $URL" | |
- name: Set STRESS_URL for Makefile | |
run: echo "STRESS_URL=${{steps.deploy.outputs.url}}" >> $GITHUB_ENV | |
stress-test: | |
runs-on: ubuntu-latest | |
needs: deploy | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r requirements-test.txt | |
- name: Print STRESS_URL (debugging) | |
run: echo "STRESS_URL=${{ needs.deploy.outputs.url }}" | |
- name: Run stress test | |
env: | |
STRESS_URL: ${{ needs.deploy.outputs.url }} | |
run: | | |
make stress-test STRESS_URL=${{ env.STRESS_URL}} |