Giter Site home page Giter Site logo

Comments (1)

averikitsch avatar averikitsch commented on May 25, 2024

Hi @martinandersen3d, you can achieve this by specifying the trigger type and branch. There are a few ways to do this. But the main idea is specifying which branch will trigger the workflow.

You could set up 2 different workflow files:

on:
  push:
    branches: [ main ]
jobs:
  Deploy_Google_App_Engine:
    name: Deploy To Google App Engine
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: google-github-actions/deploy-appengine@main
        with:
          credentials: ${{ secrets.GOOGLE_CLOUD_PLATFORM_CREDENTIALS }}
          version: server1_prod 
          # Or you could specify project_id if deploying to a different GCP project or deliverable and specify a different app.yaml ie app.prod.yaml
on:
  push:
    branches: [ staging ]
jobs:
  Deploy_Google_App_Engine:
    name: Deploy To Google App Engine
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: google-github-actions/deploy-appengine@main
        with:
          credentials: ${{ secrets.GOOGLE_CLOUD_PLATFORM_CREDENTIALS }}
          version: server2_beta 

Or you could set up one workflow file and for every push to the branch (or merged PR into the branch) 'main' and 'staging' would start this workflow:

on:
  push:
    # Sequence of patterns matched against refs/heads
    branches:    
      # Push events on main branch
      - main
      # Push events to branches matching refs/heads/staging
      - staging

However, you would need expressions to specify where you are deploying.

jobs:
  prod:
    name: Deploy To Google App Engine
    if: ${{ github.ref == 'refs/heads/main' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: echo "Deploying to production server on branch $GITHUB_REF"
      - uses: google-github-actions/deploy-appengine@main
        with:
          credentials: ${{ secrets.GOOGLE_CLOUD_PLATFORM_CREDENTIALS }}
          version: server1_prod
          # Or you could specify project_id if deploying to a different GCP project or deliverable and specify a different app.yaml ie app.prod.yaml

  staging:
    name: Deploy To Google App Engine
    if: ${{ github.ref == 'refs/heads/staging' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: echo "Deploying to staging server on branch $GITHUB_REF"
      - uses: google-github-actions/deploy-appengine@main
        with:
          credentials: ${{ secrets.GOOGLE_CLOUD_PLATFORM_CREDENTIALS }}
          version: server2_beta

There are other ways to use conditionals if you don't want to specify the job twice.

from deploy-appengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.