Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/github_script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test GitHub script
on:
workflow_dispatch:

jobs:
build-container:
name: Test some script
runs-on: ubuntu-latest
steps:
- run: |
echo "Hello World"

test-script:
needs: build-container
name: Test some script
runs-on: ubuntu-latest
steps:
- name: Test building a URL from github context
uses: actions/github-script@v6
with:
script: |
const run_url = github.server_url + '/' + github.repository + '/actions/runs/' + github.run_id
message = "This is a message"
message += '\n' + run_url
console.log(message)
- name: Test using Environment variables within JavaScript
uses: actions/github-script@v6
env:
FOO: BAR
with:
script: |
const { FOO } = process.env
if (`${FOO}` == 'BAR') {
console.log("True")
}
console.log('https://${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id}}')
console.log('needs.build-container.result = ${{ needs.build-container.result }}')
console.log(`FOO = ${FOO}`)
console.log(${{ github.server_url }})
2 changes: 1 addition & 1 deletion .github/workflows/issue_comment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
# Attempt to understand how this works
name: Invoke PR comment Workflow

on:
Expand Down
47 changes: 46 additions & 1 deletion .github/workflows/workflow_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: A workflow for my Hello World file
on:
workflow_dispatch:
jobs:
build:
test-show-inside-container:
name: Show what is inside a container
runs-on: ubuntu-latest
steps:
Expand All @@ -20,3 +20,48 @@ jobs:
- run: |
# If FOO is set from action-b then env vars ARE persisted
echo "FOO=${FOO}"

test-error-throw:
name: Test how to handle errors
runs-on: ubuntu-latest
steps:
- name: top the action running
run: |
exit 1

test-error-handle:
needs: test-error-throw
if : ${{ always() && needs.test-error.result=='failure' }}
name: Test handling errors
runs-on: ubuntu-latest
steps:
- name: Handle the errors
run: |
echo "I'm going to handle the error!"

test-json-as-env-var:
name: Test passing JSON as an environment variable
runs-on: ubuntu-latest
steps:
- name: Prepare JSON
run: |
CONFIGURATION='
{
"webapp-service" : {
"ENTRYPOINT_K8S_API_URL": "api-::ephemeral_string::.k8s-green.eu-west-1.non-prod.mydomain.net",
"ENTRYPOINT_K8S_STATIC_PATH":" www-::ephemeral_string::.k8s-green.eu-west-1.non-prod.mydomain.net",
"ENTRYPOINT_K8S_BASE_URL": "www-::ephemeral_string::.k8s-green.eu-west-1.non-prod.mydomain.net"
},
"homepage-service" : {
"ENTRYPOINT_K8S_API_URL": "api-::ephemeral_string::.k8s-green.eu-west-1.non-prod.mydomain.net",
"ENTRYPOINT_K8S_WWW_URL": "www-::ephemeral_string::.k8s-green.eu-west-1.non-prod.mydomain.net"
},
"website-service" : {
"COOKIE_DOMAIN" : "mydomain.net"
}
}'
echo $CONFIGURATION | jq --compact-output .
# TODO:
# Store as env var
# Use jq to subsequently extract particular config
# Scrap this approach and use a .yaml file?