Skip to content

Commit

Permalink
Action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantson committed May 25, 2022
1 parent 9f3952d commit 634fa30
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/action-approval-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Use secrets and environments

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Limit the permissions of the GITHUB_TOKEN
permissions:
contents: read
actions: read
deployments: write

env:
URL1: 'https://github.com'
URL2: 'https://docs.github.com'

jobs:
use-environment-1:
name: Use environment 1
runs-on: ubuntu-latest
# Use conditionals to control whether the job is triggered or skipped
if: ${{ github.event_name == 'pull_request' }}

# An environment can be specified per job
# We can use variables and expressions in the URL field
# If the environment cannot be found, it will be created
environment:
name: test
url: ${{ env.URL1 }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Some step using the environment
run: echo "In this step we could for example do the deployment to ${{ env.URL1 }} ..."

use-environment-2:
name: Use environment 2
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

environment:
name: prod
url: ${{ env.URL2 }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Some actions logic
run: echo "In this step we could for example do the deployment to ${{ env.URL2 }}..."

- name: Dump GitHub context
id: github_context_step
run: echo '${{ toJSON(github) }}'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Sample GitHub Actions workflows included in this repo
| [`.github/workflows/action-migrate-containers.yml`](/.github/workflows/action-migrate-containers.yml) | Example of migrating containers from DockerHub to GitHub Container registry |
| [`.github/workflows/action-send-slack.yml`](/.github/workflows/action-send-slack.yml) | Example of sending a Slack message from Actions |
| [`.github/workflows/action-discover-projectoboard.yml`](/.github/workflows/action-discover-projectoboard.yml) | Example of discovering Project Board |
| [`.github/workflows/action-approval-workflow.yml`](/.github/workflows/action-approval-workflow.yml) | Example of approval Action workflow |

Sample GitHub Package registry codes included in this repo

Expand Down

0 comments on commit 634fa30

Please sign in to comment.