Last active
February 28, 2023 17:44
-
-
Save dacbd/11b211016f5eb075663b25615e509f86 to your computer and use it in GitHub Desktop.
Actions workflow inherit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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