lglima / poc-github-actions

POC with Github Actions examples 🤖

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

poc-github-actions

title

This repository is a Github Actions POC with various examples regarding how to create workflows 🤖

Contents 🇧🇷

Workflow YAML Basic Structure Explanation

name: Github action workflow name

on:
  push: # Run this workflow every time a new commit pushed to the repository
  pull_request:  # Run this workflow every time a new pull request is opened to the repository
  scheduled: # Run this workflow as a cron job
    - cron: "0 0 * * *"
  workflow_dispatch: # Run this workflow on demand (manually)

jobs: # All workflows need at list one job

  job-key: #First job
    name: Job Name
    runs-on: ubuntu-latest # Set the type of machine the workflow will run on
    steps: # Each job can be divided in many steps

      - name: Checkout code # Step name
        uses: actions/checkout@v2 # Action used on the step

      - name: Run Super-Linter # Another step name
        uses: github/super-linter@v3  # Action used on the step
        env:  # Environment variables used on the step
          DEFAULT_BRANCH: main
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Run specific commands # Another step name
        run: |
          ls -lha
          echo "This is a shell command"

Examples

01 - Default Workflow

This workflow uses CRON to run some basic commands.

02 - Secret Workflow

This workflow uses CRON to run some basic commands using repository secrets.

03 - Python Script Workflow

This workflow uses CRON to execute a specific script run.py located on the repository.

04 - Remote Dispatch Action Initiator

This workflow uses CRON to dispatch an event to the ritchie-formulas-scheduler-demo repository.

05 - Container Workflow

This workflow uses CRON with a docker container where Ritchie CLI and Golang are installed, then check Ritchie CLI and Golang versions through commands.

06 - Docker Image Workflow

This workflow uses CRON and a docker image foundeo/minibox:latest. It also specify an entrypoint (the command to run inside the container) and args (command line arguments to pass to the command specified in entrypoint). It is possible to omit the entrypoint if the container already species the entrypoint you want to use.

07 - Action workflow

This workflow will run an Action each time a PUSH event occurs on the repository. This specific action runs a Ritchie CLI formula.

08 - Outputs workflow

This workflow illustrates how to set outputs in a job to use them on another job. This specific workflow prints Hello-World.

09 - Artifacts workflow

This workflow illustrates how to pass data between jobs in the same workflow. For more information, see the actions/upload-artifact and download-artifact actions. The full math operation performed in this workflow example is (3 + 7) x 9 = 90.

10 - Environment workflow

This workflow illustrates how to use environment variables from the whole workflow, a specific job, or a specific step.

11 - Input workflow

This workflow illustrates how to use input variables on a workflow_dispatch event.

12 - Run Workflow

This workflow illustrates how to run a workflow once another specific one has been completed (with success or failure).

13 - Create Pull Request

This workflow uses CRON to automatically create a Pull Request committing updated files.

14 - Auto Merge

This workflow illustrates how to automatically merge a Pull Request with a specific label automerge.

15 - Push Dev

This workflow only run when a push is made to the dev branch. Note that with this implementation, the workflow needs to be present on the specific branch as well (here dev).

16 - Conditional

This workflow illustrates how to use conditional through the if variable.

17 - Issue Greeter

This workflow illustrates how to write an automatic comment on a new issue, without using action, through the github API.

18 - Specific File

This workflow illustrates how to trigger a workflow when specific files are updated by a push or pull_request event.

19 - Push Event

This workflow illustrates how use the checkout action to create a push event, updating a file and committing it to the branch.

20 - Generate Patch Tag with Cherry Pick

This workflow illustrates how use cherry-pick to generate a new repository tag informing 3 inputs (reference tag, new tag, and commit hash).

21 - Generate Release Branch with Cherry Pick

This workflow illustrates how use cherry-pick to generate a new release branch informing 3 inputs (reference tag, new tag, and commit hash).

22 - Install runner tools

This workflow illustrates how to install tools not supported by the ubuntu runner using apt-get install.

23 - Upload reset Asset

This workflow illustrates how to upload a release asset. Example

24 - Github Context

This workflow illustrates how to access various context variables on a workflow.

25 - Artifacts between Workflows 1 25 - Artifacts between Workflows 2

These workflows illustrate how to share datas between various workflows using artifacts.

26 - Create branch on another repo

This workflow illustrates how to create a new branch on another repository based on the current repository tag.

27 - Check Tags

This workflow illustrates how to use outputs between jobs with the needs context to check tags and manage them to perfom some operation according to their name.

28 - Create Pull Request (Workflow)

This workflow illustrates how to create a new Pull Request based on a branch name after a push event.

About

POC with Github Actions examples 🤖

License:Apache License 2.0


Languages

Language:Python 100.0%