yalegria / devops-git-actions

0 stars 0 forks source link

Setup GitHub Actions within a repository. #4

Closed yuriaru closed 3 years ago

Voxelghiest commented 3 years ago

Alright, so here are the steps one needs to take to set up actions in a repo:

  1. Go to the "Actions" tab in the repo.
  2. Select a premade workflow or click "set up a workflow yourself". When you do so, GitHub automatically creates a folder at the root of your repo called .github, and another folder in there called workflows, which is where the actions are stored as YAML files. You can edit them like any other element of your repo, or add new ones directly to the .github/workflows folder if you would like.
  3. Add or Edit the current action and then press "Start Commit".
Voxelghiest commented 3 years ago

Here's a sample action you can use to understand the structure of an action. Put this all into a YAML file and then add that file to the .github/workflows folder after you have set up the repo for actions:

name: Sample Action
on:
  push:
    branches:
      - main
jobs:
  sampleJob:
    # You can give your job a name, select the runner to host it, and create environment variables
    name: Sample Job
    runs-on: ubuntu-latest
    env:
      MESSAGE: "Hello World"
    # These are the steps that the job takes
    steps:
      - name: Checkout Project
        uses: actions/checkout@v2
      - run: echo $MESSAGE
yuriaru commented 3 years ago

Done