diff --git a/.github/workflows/docker-gcp.yml b/.github/workflows/docker-gcp.yml index 1db8577..36d6e77 100644 --- a/.github/workflows/docker-gcp.yml +++ b/.github/workflows/docker-gcp.yml @@ -11,12 +11,14 @@ on: - 'DESCRIPTION' - 'NAMESPACE' workflow_dispatch: - + env: GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} GCP_REGION: ${{ secrets.GCP_REGION }} GCP_SERVICE_ACCOUNT_CREDENTIALS: ${{ secrets.GCP_SERVICE_ACCOUNT_CREDENTIALS }} GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} + GCP_GAR_NAME: "demo-rshiny-cloudrun" + APP_NAME: "rshinycloudrun" REPOSITORY_NAME: ${{ github.repository }} APP_NAME: rshinycloudrun @@ -32,14 +34,14 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - + - name: Google Auth id: auth uses: google-github-actions/auth@v2 with: token_format: 'access_token' credentials_json: ${{ env.GCP_SA_KEY }} - + - name: Set up Cloud SDK id: setup-cloud-sdk uses: google-github-actions/setup-gcloud@v2 @@ -48,7 +50,7 @@ jobs: - name: Verify gcloud CLI run: gcloud info - + - name: Docker Auth id: docker-auth run: |- @@ -60,15 +62,10 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Get Image Tag - id: get-image-tag - run: |- - echo ::set-env name=IMAGE_TAG::${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.REPOSITORY_NAME }}/${{ env.APP_NAME }}:${{ github.sha }} - - name: Build and Push Container id: build run: |- - docker build -t ${{ env.IMAGE_TAG }} . + docker build --build-arg R_CONFIG_ACTIVE=production . --tag $GCP_REGION-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_GAR_NAME/$APP_NAME:$GITHUB_SHA docker push ${{ env.IMAGE_TAG }} - name: Deploy to Cloud Run @@ -76,12 +73,12 @@ jobs: uses: google-github-actions/deploy-cloudrun@v1 with: service: ${{ env.APP_NAME }} - image: ${{ env.IMAGE_TAG }} + image: $GCP_REGION-docker.pkg.dev/$GCP_PROJECT_ID/$GCP_GAR_NAME/$APP_NAME:$GITHUB_SHA region: ${{ env.GCP_REGION }} platform: managed allow-unauthenticated: true env_vars: | R_CONFIG_ACTIVE=production - + - name: Output Service URL run: echo ${{ steps.deploy.outputs.url }}