|
| 1 | +name: Hello World |
| 2 | + |
| 3 | +# Controls when the workflow will run |
| 4 | +on: |
| 5 | + # Triggers the workflow on push or pull request events but only for the default branch |
| 6 | + push: |
| 7 | + branches: [ "main", "master" ] |
| 8 | + pull_request: |
| 9 | + branches: [ "main", "master" ] |
| 10 | + |
| 11 | + # Allows you to run this workflow manually from the Actions tab |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 15 | +jobs: |
| 16 | + # This workflow contains a single job called "greet" |
| 17 | + greet: |
| 18 | + # The type of runner that the job will run on |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 22 | + steps: |
| 23 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + |
| 26 | + # Runs a single command using the runners shell |
| 27 | + - name: Say Hello |
| 28 | + run: echo "Hello, World! π" |
| 29 | + |
| 30 | + # Runs a set of commands using the runners shell |
| 31 | + - name: Multi-line greeting |
| 32 | + run: | |
| 33 | + echo "Welcome to GitHub Actions!" |
| 34 | + echo "Repository: ${{ github.repository }}" |
| 35 | + echo "Actor: ${{ github.actor }}" |
| 36 | + echo "Event: ${{ github.event_name }}" |
| 37 | + echo "Branch: ${{ github.ref_name }}" |
| 38 | +
|
| 39 | + # Example of using environment variables |
| 40 | + - name: Greet with environment variables |
| 41 | + env: |
| 42 | + NAME: "GitHub Actions" |
| 43 | + EMOJI: "π" |
| 44 | + run: | |
| 45 | + echo "Hello from $NAME $EMOJI" |
| 46 | + echo "Current date: $(date)" |
| 47 | +
|
| 48 | + # Example of conditional step |
| 49 | + - name: Special message for main branch |
| 50 | + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' |
| 51 | + run: echo "This is running on the main branch! π" |
0 commit comments