diff --git a/.github/actions/hello-world-composite-action/action.yml b/.github/actions/hello-world-composite-action/action.yml index 18611d5d..12753942 100644 --- a/.github/actions/hello-world-composite-action/action.yml +++ b/.github/actions/hello-world-composite-action/action.yml @@ -18,4 +18,12 @@ runs: run: echo "random-id=$(echo $RANDOM)" >> $GITHUB_OUTPUT shell: bash - run: echo "${{ github.action_path }}" >> $GITHUB_PATH - shell: bash + shell: bash + - name: Hello world + uses: actions/hello-world-javascript-action@main + with: + who-to-greet: "${{ inputs.who-to-greet }}" + id: hello + - name: Echo the greeting's time + run: echo 'The time was ${{ steps.hello.outputs.time }}.' + shell: bash diff --git a/.github/workflows/cd-workflow.yml b/.github/workflows/cd-workflow.yml index f8a46600..7145a539 100644 --- a/.github/workflows/cd-workflow.yml +++ b/.github/workflows/cd-workflow.yml @@ -1,9 +1,8 @@ name: 07-2. CD Workflow on: - # push: - # branches: [main] - workflow_dispatch: + push: + branches: [main] env: AZURE_WEBAPP_NAME: your-app-name # set this to your application's name @@ -51,7 +50,10 @@ jobs: steps: # Add here the download-artifact step - + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: node-app - name: Deploy to Prod if: ${{ success() }} diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 14ff2afe..e554056b 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -23,8 +23,8 @@ jobs: fail-fast: true matrix: # our matrix for testing across node versions and OSs - node-version: [12, 14] - os: [windows-2019, ubuntu-20.04, ubuntu-22.04] + node-version: [12, 14, 16] + os: [macos-latest, windows-latest, ubuntu-latest] steps: - name: Checkout @@ -43,7 +43,14 @@ jobs: echo npm test # Add here the upload-artifact action - + - shell: bash + run: | + echo 'Test upload artifact' > output.log + - name: Upload output file + uses: actions/upload-artifact@v4 + with: + name: output-log-file + path: output.log # If both linting and CI succeeds we want to deploy the code to a test environment deploy-test: @@ -58,7 +65,10 @@ jobs: uses: actions/checkout@v4 # Add here the download-artifact step - + - name: Download a single artifact + uses: actions/download-artifact@v4 + with: + name: output-log-file # Placeholder - this step would be some action or run commands that deploys the code - name: Deploy to test env diff --git a/.github/workflows/environments-secrets.yml b/.github/workflows/environments-secrets.yml index 2b128265..77c6df61 100644 --- a/.github/workflows/environments-secrets.yml +++ b/.github/workflows/environments-secrets.yml @@ -1,10 +1,10 @@ name: 03-1. Environments and Secrets on: - # push: - # branches: [main] - # pull_request: - # branches: [main] + push: + branches: [main] + pull_request: + branches: [main] workflow_dispatch: # Limit the permissions of the GITHUB_TOKEN @@ -19,6 +19,25 @@ env: DEV_URL: 'https://docs.github.com/en/developers' jobs: + + use-secrets: + name: Use secrets + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + steps: + - name: Hello world action with secrets + uses: actions/hello-world-javascript-action@main + with: # Set the secret as an input + who-to-greet: ${{ secrets.MY_REPO_SECRET }} + env: # Or as an environment variable + super_secret: ${{ secrets.MY_REPO_SECRET }} + - name: Echo secret is redacted in the logs + run: | + echo Env secret is ${{ secrets.MY_REPO_SECRET }} + echo Warning: GitHub automatically redacts secrets printed to the log, + echo but you should avoid printing secrets to the log intentionally. + echo ${{ secrets.MY_REPO_SECRET }} | sed 's/./& /g' + use-environment-dev: name: Use DEV environment runs-on: ubuntu-latest @@ -72,12 +91,30 @@ jobs: echo Org secret is ${{ secrets.MY_ORG_SECRET }} echo Env secret is not accessible ${{ secrets.MY_ENV_SECRET }} + + use-environment-uat: + name: Use UAT environment + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + needs: use-environment-test + + environment: + name: UAT + url: 'https://uat.github.com' + + steps: + - name: Step that uses the UAT environment + run: echo "Deployment to UAT..." + env: + env_secret: ${{ secrets.MY_ENV_SECRET }} + + use-environment-prod: name: Use PROD environment runs-on: ubuntu-latest #if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - needs: use-environment-test + needs: use-environment-uat environment: name: PROD diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index e8540e80..1b0e1d45 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -2,6 +2,9 @@ name: 01-1. GitHub Actions Demo on: workflow_dispatch: workflow_call: + push: + branches: + - main jobs: Explore-GitHub-Actions: @@ -20,3 +23,12 @@ jobs: - run: echo "🍏 This job's status is ${{ job.status }}." - name: Adding markdown run: echo "### Hello world! :rocket:" >> "$GITHUB_STEP_SUMMARY" + # This step uses GitHub's hello-world-javascript-action: https://github.com/actions/hello-world-javascript-action + - name: Hello world + uses: actions/hello-world-javascript-action@main + with: + who-to-greet: "Mona the Octocat" + id: hello + # This step prints an output (time) from the previous step's action. + - name: Echo the greeting's time + run: echo 'The time was ${{ steps.hello.outputs.time }}.' diff --git a/.github/workflows/github-script.yml b/.github/workflows/github-script.yml index 230ad303..298d8fb4 100644 --- a/.github/workflows/github-script.yml +++ b/.github/workflows/github-script.yml @@ -21,4 +21,16 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: '👋 Thank you! We appreciate your contribution to this project.' + }) + apply-label: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + with: + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['Training'] }) \ No newline at end of file diff --git a/.github/workflows/hello-world-composite.yml b/.github/workflows/hello-world-composite.yml index 989d1f8c..0c045402 100644 --- a/.github/workflows/hello-world-composite.yml +++ b/.github/workflows/hello-world-composite.yml @@ -1,7 +1,9 @@ name: 05-2. Hello World Composite -on: - [workflow_dispatch] +on: + pull_request: + branches: [main] + workflow_dispatch: jobs: hello_world_job1: @@ -14,3 +16,15 @@ jobs: who-to-greet: 'Hello from GH ABCs' - run: echo random-number ${{ steps.hello-world.outputs.random-number }} shell: bash + + hello_world_job2: + runs-on: ubuntu-latest + name: A job2 to say hello + steps: + - uses: actions/checkout@v4 + - id: hello-world + uses: ./.github/actions/hello-world-composite-action + with: + who-to-greet: 'Mona the Octocat from composite action' + - run: echo random-number from composite action ${{ steps.hello-world.outputs.random-number }} + shell: bash diff --git a/.github/workflows/job-dependencies.yml b/.github/workflows/job-dependencies.yml index e773fe04..23c46d32 100644 --- a/.github/workflows/job-dependencies.yml +++ b/.github/workflows/job-dependencies.yml @@ -1,10 +1,10 @@ name: 02-2. Dependencies on: - workflow_dispatch: - # push: - # branches: - # - main + workflow_call: + push: + branches: + - main jobs: initial: @@ -31,3 +31,41 @@ jobs: needs: [fanout1, fanout2] steps: - run: echo "This job will run after fanout1 and fanout2 have finished." + + build: + runs-on: ubuntu-latest + strategy: + matrix: + configuration: [debug, release] + steps: + - run: echo "This job builds the cofiguration ${{ matrix.configuration }}." + test: + runs-on: ubuntu-latest + needs: build + steps: + - run: echo "This job will be run after the build job." + ring01: + runs-on: ubuntu-latest + needs: test + steps: + - run: echo "This job will be run after the test job." + ring02: + runs-on: macos-latest + needs: test + steps: + - run: echo "This job will be run after the test job." + ring03: + runs-on: ubuntu-latest + needs: test + steps: + - run: echo "This job will be run after the test job." + ring04: + runs-on: ubuntu-latest + needs: [ring01,ring02,ring03] + steps: + - run: echo "This job will be run after the ring01,ring02,ring03 jobs." + prod: + runs-on: ubuntu-latest + needs: [ring04] + steps: + - run: echo "This job will be run after the ring04 job." diff --git a/.github/workflows/reusable-workflow-template.yml b/.github/workflows/reusable-workflow-template.yml index 33c7858e..8bf282ae 100644 --- a/.github/workflows/reusable-workflow-template.yml +++ b/.github/workflows/reusable-workflow-template.yml @@ -1,7 +1,9 @@ name: 04-1. Call Reusable Workflow Templates -on: - [workflow_dispatch] +on: + push: + branches: [main] + workflow_dispatch: jobs: call_greet_everyone_workflow_job: @@ -15,3 +17,7 @@ jobs: call_demo_workflow_job: needs: call_greet_everyone_workflow_job uses: githubabcs/gh-abcs-actions/.github/workflows/github-actions-demo.yml@main + + call_dependencies_workflow_job: + needs: call_reusable_workflow_job + uses: /gh-abcs-actions/.github/workflows/job-dependencies.yml@main diff --git a/.github/workflows/use-custom-actions.yml b/.github/workflows/use-custom-actions.yml index 55beb2bf..26f0d08a 100644 --- a/.github/workflows/use-custom-actions.yml +++ b/.github/workflows/use-custom-actions.yml @@ -32,7 +32,7 @@ jobs: with: repo-token: ${{secrets.GITHUB_TOKEN}} joke: ${{steps.jokes.outputs.joke-output}} - issue-title: "A joke for you from ${{ github.actor }}" + issue-title: "A joke for you from custom actions workflow" docker-custom-actions: runs-on: ubuntu-latest