Giter VIP home page Giter VIP logo

73h / gae-app-yaml-replace-env-variables Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 5.0 27 KB

If you are using Googles App Engine and want to use secrets in the app.yaml file, you can store them as Secrets in your repository and have them replaced during deployment.

Home Page: https://blog.73h.de/article/ersetzen-von-secrets-beim-automatischen-deployment-in-googles-app-engine

License: MIT License

Dockerfile 13.46% Python 86.54%
action actions deployment github-actions env env-file google-app-engine google-appengine secrets

gae-app-yaml-replace-env-variables's Introduction

Replace secrets for Googles App Engine Deployment

If you are using Googles App Engine and want to use secrets in the app.yaml file, you can store them as Secrets in your repository and have them replaced during deployment.

Test-Workflow


Usage

Place the following in your /.github/workflows/main.yml behind actions/checkout@v2.

...
steps:
  - uses: actions/checkout@v2
  - uses: 73h/[email protected]
    env:
      SECRET_ONE: ${{ secrets.SECRET_ONE }}
      ANOTHER_SECRET: ${{ secrets.ANOTHER_SECRET }}
    with:
      app_yaml_path: "app.yaml"
...

Extract app.yaml

...
env_variables:
  APP_ENV: production
  SECRET_ONE: $SECRET_ONE
  ANOTHER_SECRET: $ANOTHER_SECRET
...

Full Example with Google's App Engine

An example with Google's App Engine (GAE) deployment.

/.github/workflows/main.yml

on: push
name: Deploy site on push
jobs:
  deploy_on_googles_app_engine:
    name: Deploy
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: 73h/[email protected]
        env:
          SECRET_ONE: ${{ secrets.SECRET_ONE }}
          SECRET_TWO: ${{ secrets.SECRET_TWO }}
        with:
          app_yaml_path: "app.yaml"
      - uses: 'google-github-actions/auth@v0'
        with:
          credentials_json: '${{ secrets.GCP_SA_JSON }}'
      - uses: 'google-github-actions/deploy-appengine@v0'
        with:
          deliverables: 'app.yaml'
          promote: true
          version: 'v1'

The full app.yaml file looks like this.

runtime: python39
entrypoint: gunicorn -b :$PORT main:app --chdir app
handlers:
  - url: /.*
    script: auto
    secure: always
    redirect_http_response_code: 301
automatic_scaling:
  max_instances: 1
env_variables:
  APP_ENV: production
  SECRET_ONE: $SECRET_ONE
  SECRET_TWO: $SECRET_TWO
  ANOTHER_PARAM: "73"

Settings

Key Name Required Examples Default Value Description
app_yaml_path No config/app.yaml
myapp.yaml
app.yaml full path to your app.yaml file

gae-app-yaml-replace-env-variables's People

Contributors

73h avatar alkshmir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gae-app-yaml-replace-env-variables's Issues

cannot find the env-variable HOST in "env" section in github action workflow

Hi,

Im trying to use this github action but it seems that it's not able to read the env section from the workflow and Im not able to figure out why. All the secrets have been set in my Github repo .

Here is the step in my job using the action.

    steps:
      - uses: actions/checkout@v2
      - uses: 73h/[email protected]
        env:
          HOST: ${{ secrets.HOST }}
        with:
          app_yaml_path: 'gcp-staging.yaml'

My gcp-staging.yaml file :

runtime: nodejs16
instance_class: F2

handlers:
  - url: /_nuxt
    static_dir: .nuxt/dist/client
    secure: always

  - url: /(.*\.(gif|png|jpg|ico|txt))$
    static_files: static/\1
    upload: static/.*\.(gif|png|jpg|ico|txt)$
    secure: always

  - url: /.*
    script: auto
    secure: always

env_variables:
  HOST: $SECRET_HOST

The error triggered when running the job :

  File "/app/main.py", line 35, in <module>
    replace_env_variables_in_app_yaml_file()
  File "/app/main.py", line 27, in replace_env_variables_in_app_yaml_file
    raise Exception(f"cannot find the env-variable {key} in \"env\" section in github action workflow")
Exception: cannot find the env-variable HOST in "env" section in github action workflow

Is there something wrong in my yaml files ?
Thanks in advance for your help.

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.