dkuzmenko-dsr is testing out GitHub Actions π #53
This file contains 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: 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 }}' | |
# }) |