Skip to main content

Integrating with Cloud Providers

1. Deploying to AWS

Option Values Notes
uses aws-actions/deploy-to-aws-lambda@v1 Deploy to AWS Lambda
uses aws-actions/deploy-to-ecs@v1 Deploy to AWS ECS
uses aws-actions/configure-aws-credentials@v1 Configure AWS credentials for actions

Example: Deploy to AWS Lambda

name: Deploy to AWS Lambda
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Deploy to Lambda
        uses: aws-actions/deploy-to-aws-lambda@v1
        with:
          function-name: my-function
          zip-file: ./function.zip

Example: Deploy to AWS ECS

name: Deploy to AWS ECS
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Deploy to ECS
        uses: aws-actions/deploy-to-ecs@v1
        with:
          service-name: my-service
          cluster-name: my-cluster
          task-definition-path: ./task-definition.json

2. Using AWS CLI

Command Description Notes
aws configure Set up AWS credentials and default region Interactive setup or use environment variables
aws sts get-caller-identity Verify AWS credentials and account info Useful for testing authentication
aws s3 ls List S3 buckets Requires proper IAM permissions
aws s3 cp Copy files to/from S3 Supports local and remote paths

Example: Configure AWS CLI in GitHub Actions

name: Deploy to AWS
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1

Example: Upload to S3 using CLI

- name: Upload to S3
  run: |
    aws s3 cp ./dist s3://my-bucket/dist --recursive
Note: Ensure that the IAM role or user has appropriate permissions for the AWS CLI commands being executed.

3. Deploying to Azure

Option Values Notes
uses azure/webapps-deploy@v2 GitHub Action for deploying to Azure Web Apps
app-name my-web-app Name of the Azure Web App to deploy to
package ./dist Path to the application package or folder
publish-profile ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} Secret containing the publish profile for Azure

Example: Deploying a Node.js App to Azure

name: Deploy to Azure Web App
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm install
      - run: npm run build
      - name: Deploy to Azure Web App
        uses: azure/webapps-deploy@v2
        with:
          app-name: my-node-app
          package: ./dist
          publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
Note: The AZURE_WEBAPP_PUBLISH_PROFILE secret must be created in your GitHub repository settings under Settings > Secrets and variables > Actions.
Warning: Ensure that the Azure Web App is configured to accept deployments from GitHub Actions. This typically involves setting up the correct deployment credentials and ensuring that the app's configuration allows for CI/CD.

4. Using Azure CLI

Command Description Notes
az login Log in to Azure CLI Required before running other commands
az account show Display current account info Verifies successful login
az group create Create a resource group Essential for organizing resources
az webapp deployment Deploy web apps to Azure Supports various deployment methods

Example: Deploying a Web App

az webapp deployment source config-zip \
  --resource-group myResourceGroup \
  --name myWebApp \
  --src-url https://github.com/user/repo/archive/main.zip
Note: Ensure the Azure CLI is installed and authenticated in your GitHub Actions workflow.
Warning: Avoid exposing Azure credentials in plain text. Use GitHub Secrets for sensitive data.

5. Deploying to GCP

Option Values Notes
uses google-github-actions/deploy-cloud-run@v0 GitHub Action for deploying to Google Cloud Run
with.service my-service Name of the Cloud Run service to deploy to
with.image gcr.io/my-project/my-image Docker image to deploy
with.region us-central1 Region where the Cloud Run service is located

Example: Deploying a Docker image to GCP Cloud Run

name: Deploy to GCP Cloud Run
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set up Cloud Run
        uses: google-github-actions/deploy-cloud-run@v0
        with:
          service: my-service
          image: gcr.io/my-project/my-image
          region: us-central1
Note: Ensure that the GCP service account has the necessary permissions to deploy to Cloud Run.
Warning: The image must be available in a container registry accessible to GCP.

6. Using GCP CLI

Command Description Example
gcloud auth list Lists authenticated accounts gcloud auth list
gcloud config list Displays current configuration values gcloud config list
gcloud projects list Lists all GCP projects accessible to the user gcloud projects list
gcloud compute instances list Lists Compute Engine instances in a zone gcloud compute instances list --zone=us-central1-a
gcloud storage ls Lists Cloud Storage buckets and objects gcloud storage ls gs://my-bucket

Example: Authenticate and deploy to GCP

name: Deploy to GCP
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Google Cloud CLI
        uses: google-github-actions/setup-gcloud@v2
        with:
          project_id: my-gcp-project-id
          service_account_key: ${{ secrets.GCP_SA_KEY }}

      - name: Deploy to App Engine
        run: |
          gcloud app deploy --quiet
Note: Ensure the service account has appropriate IAM roles such as roles/appengine.appAdmin for App Engine deployments.
Warning: The GCP_SA_KEY secret should be securely stored in your GitHub repository settings to avoid exposing credentials.

7. Deploying to Vercel

GitHub Actions can automate deployments to Vercel, enabling continuous deployment of web applications directly from your repository.

Option Values Description
uses vercel/vercel-action@v25 The official Vercel GitHub Action for deployment
with.vercel_token ${{ secrets.VERCEL_TOKEN }} Vercel API token with deployment permissions
with.project_id ${{ secrets.VERCEL_PROJECT_ID }} Unique identifier for the Vercel project
with.environment production or preview Environment to deploy to (production or preview)

Example: Basic Vercel Deployment

name: Deploy to Vercel
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy to Vercel
        uses: vercel/vercel-action@v25
        with:
          vercel_token: ${{ secrets.VERCEL_TOKEN }}
          project_id: ${{ secrets.VERCEL_PROJECT_ID }}
Note: Ensure the VERCEL_TOKEN and VERCEL_PROJECT_ID are set in your repository's secrets.
Warning: The Vercel token must have deploy scope to allow deployments.

Deployment Workflow Summary

  • Triggers on push to the main branch
  • Checks out the repository code
  • Uses Vercel's official GitHub Action to deploy
  • Deploys to the project specified in VERCEL_PROJECT_ID

8. Deploying to Netlify

Option Values Notes
uses netlify/actions/deploy@v3 GitHub Action for Netlify deployment
with.site-id netlify-site-id Netlify site ID (required)
with.netlify-token NETLIFY_TOKEN Netlify API token (required)
with.publish-dir dist Directory to deploy (default: dist)

Example: Deploying to Netlify

name: Deploy to Netlify
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build project
        run: npm run build
      - name: Deploy to Netlify
        uses: netlify/actions/deploy@v3
        with:
          site-id: "your-netlify-site-id"
          netlify-token: ${{ secrets.NETLIFY_TOKEN }}
          publish-dir: ./dist
Note: Ensure the NETLIFY_TOKEN is set in your repository secrets.

9. Deploying to Heroku

Option Values Notes
uses actions/deploy@v1 Deploy action for Heroku
with.app-name my-heroku-app Name of the Heroku app to deploy to
with.heroku-api-key ${{ secrets.HEROKU_API_KEY }} Heroku API key from GitHub secrets

Example: Deploying to Heroku

name: Deploy to Heroku
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Deploy to Heroku
        uses: actions/deploy@v1
        with:
          app-name: my-heroku-app
          heroku-api-key: ${{ secrets.HEROKU_API_KEY }}
Note: Ensure the Heroku API key is stored in GitHub Secrets under the name HEROKU_API_KEY.

10. Using DigitalOcean

Option Values Notes
uses digitalocean/action@v1 GitHub Action for DigitalOcean
with.token secrets.DIGITALOCEAN_TOKEN DigitalOcean API token
with.region nyc1 Region to deploy to
with.size s-1vcpu-1gb Droplet size

Example: Deploy to DigitalOcean

name: Deploy to DigitalOcean
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Deploy to DigitalOcean
        uses: digitalocean/action@v1
        with:
          token: ${{ secrets.DIGITALOCEAN_TOKEN }}
          region: nyc1
          size: s-1vcpu-1gb
Note: Ensure your DIGITALOCEAN_TOKEN is set in GitHub Secrets.

11. Using Cloudflare

Option Values Notes
uses cloudflare/cloudflare-action@v1 GitHub Action for Cloudflare
with.zone-id string Cloudflare Zone ID
with.api-token string Cloudflare API Token with required permissions

Example: Deploy to Cloudflare Workers

name: Deploy to Cloudflare Workers
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy to Cloudflare
        uses: cloudflare/cloudflare-action@v1
        with:
          zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }}
          api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          worker-name: my-worker
Note: Ensure the API token has Workers and Zone permissions.

Key Features

  • Deploy to Cloudflare Workers
  • Manage DNS records
  • Update Page Rules

12. Managing Cloud Resources

Resource Description Action Notes
aws AWS resource management aws configure Configure AWS credentials using environment variables
gcp Google Cloud Platform resource management gcloud auth application-default login Authenticate with GCP using default credentials
azure Azure resource management az login Login to Azure CLI with service principal or device code

Example: Deploying to AWS EC2

name: Deploy to EC2
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-west-2
      - name: Deploy to EC2
        run: |
          echo "Deploying application to EC2 instance"

Example: Deploying to GCP Compute Engine

name: Deploy to GCP
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Authenticate with GCP
        uses: google-github-actions/auth@v2
        with:
          project_id: my-project-id
          service_account_key: ${{ secrets.GCP_SA_KEY }}
      - name: Deploy to GCP Compute Engine
        run: |
          gcloud compute instances update my-instance --metadata-from-file startup-script=deploy.sh

Example: Deploying to Azure Virtual Machines

name: Deploy to Azure VM
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Login to Azure
        uses: azure/login@v2
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}
      - name: Deploy to Azure VM
        run: |
          az vm run-command invoke \
            --resource-group myResourceGroup \
            --name myVM \
            --command-id RunShellScript \
            --scripts "echo 'Deploying application to Azure VM'"

Was this article helpful?