Skip to content

Instantly share code, notes, and snippets.

@dacbd
Last active February 28, 2023 17:44
Show Gist options
  • Save dacbd/11b211016f5eb075663b25615e509f86 to your computer and use it in GitHub Desktop.
Save dacbd/11b211016f5eb075663b25615e509f86 to your computer and use it in GitHub Desktop.
Actions workflow inherit
name: Deploy
on:
workflow_call:
inputs:
deploy_ref:
required: true
type: string
environment:
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.deploy_ref }}
- name: build
run: echo "build project"
- name: deploy
run: echo "deploy project ${{ secrets.MY_DEPLOY_KEY }}"
name: trigger deployment
on:
push:
branches:
- '*'
release:
types: [published]
jobs:
deploy:
# if release
# environment = prod
# else if branch == main
# environment = stage
# else
# environment = dev
uses: octo-org/example-repo/.github/workflows/deploy.yml@main
with:
environment: ${{ github.event_name == 'release' && 'prod' || (github.ref_name == 'main' && 'stage' || 'dev') }}
deploy_ref: ${{github.event.release.tag_name || github.ref_name }}
secrets: inherit
name: trigger deployment
on:
push:
branches:
- 'feature/*'
jobs:
deploy:
uses: octo-org/example-repo/.github/workflows/deploy.yml@main
with:
environment: dev
deploy_ref: ${{ github.ref_name }}
secrets: inherit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment