change to node 14 #26
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: Advanced Configuration | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
environment-variables: | |
runs-on: ubuntu-latest | |
env: | |
MY_VARIABLE: "Hello, World!" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Print environment variable | |
run: echo $MY_VARIABLE | |
- name: Set environment variable | |
run: echo "MY_VARIABLE=Hello, World!" >> $GITHUB_ENV | |
- name: Print environment variable from step | |
run: echo $MY_VARIABLE | |
conditional-execution: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run on push events | |
if: github.event_name == 'push' | |
run: echo "This step runs only on push events" | |
- name: Run on pull request events | |
if: github.event_name == 'pull_request' | |
run: echo "This step runs only on pull request events" | |
- name: Run on push to main branch | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: echo "This step runs only on push events to the main branch" | |
- name: Run on pull request to main branch | |
if: github.event_name == 'pull_request' && github.base_ref == 'main' | |
run: echo "This step runs only on pull request events to the main branch" | |
expressions-example: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print event that triggered the workflow | |
run: echo "The current date is ${{ github.event_name }}" | |
context-example: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print repository name | |
run: echo "The repository name is ${{ github.repository }}" | |
- name: Print runner OS | |
run: echo "The runner OS is ${{ runner.os }}" | |
variables-example: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set a variable | |
id: step1 | |
run: echo "::set-output name=my_var::Hello, World!" | |
- name: Use the variable | |
run: echo "The variable is ${{ steps.step1.outputs.my_var }}" | |
job1: | |
runs-on: ubuntu-latest | |
outputs: | |
my_var: ${{ steps.set-output.outputs.my_var }} | |
steps: | |
- name: Set output | |
id: set-output | |
run: echo "::set-output name=my_var::Hello, World!" | |
- name: Set variable in file | |
run: echo "MY_VARIABLE=Hello, World!" > my_variable.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: my-variable | |
path: my_variable.txt | |
job2: | |
runs-on: ubuntu-latest | |
needs: job1 | |
steps: | |
- name: Use output | |
run: echo "The variable is ${{ needs.job1.outputs.my_var }}" | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: my-variable | |
path: . | |
- name: Read variable from file | |
run: cat my_variable.txt |