Skip to content

dkuzmenko-dsr is testing out GitHub Actions πŸš€ #53

dkuzmenko-dsr is testing out GitHub Actions πŸš€

dkuzmenko-dsr is testing out GitHub Actions πŸš€ #53

name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions πŸš€
on:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
- unlabeled
- edited
issue_comment:
types:
- created
env:
labelDeploy: ${{ github.event.label.name == 'deploy' }}
titleDeploy: ${{ endsWith(github.event.pull_request.title, '[deploy]') }}
jobs:
Explore-GitHub-Actions:
if: |
true ||
github.event.label.name == 'deploy' ||
endsWith(github.event.pull_request.title, '[deploy]')
runs-on: ubuntu-latest
steps:
- run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "πŸ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "πŸ’‘ The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "πŸ–₯️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
- name: Export env variable
run: export VAR=VALUE
- name: Test env variable
run: |
echo "VAR: ${VAR}"
- name: Env config
run: |
echo "VARVAR=value" >> $GITHUB_ENV
- name: Test bash env
run: |
echo $VARVAR
- name: Test wf env
run: |
echo ${{ env.VARVAR }}
- name: Print env
run: |
env | sort
- name: GH env
run: |
env | grep GITHUB | sort
- name: GH context
env:
GH: ${{ toJson(github)}}
run: |
echo -e "Github context:\n$GH"
report:
runs-on: ubuntu-latest
needs:
- Explore-GitHub-Actions
if: needs.Explore-GitHub-Actions.result != 'skipped'
steps:
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'πŸ‘‹ CI result: ${{ needs.Explore-GitHub-Actions.result }}.\nlabelDeploy: ${{ env.labelDeploy }}\ntitleDeploy: ${{ env.titleDeploy }}'
})
# good_job:
# runs-on: ubuntu-latest
# steps:
# - name: Just print env
# run: |
# env
# bad_job:
# runs-on: ubuntu-latest
# steps:
# - name: Fail this step
# run: |
# no-such-command
# report:
# runs-on: ubuntu-latest
# if: always()
# needs:
# - bad_job
# - good_job
# steps:
# - uses: actions/github-script@v6
# with:
# script: |
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: 'πŸ‘‹ Thanks for reporting!\nGood Job: ${{ needs.good_job.result }}\nBad job: ${{ needs.bad_job.result }}'
# })