Git Product home page Git Product logo

workflow-templates's Introduction

Workflow Templates

Templates of GitHub Workflows for different programming languages. Place the workflow file you want to use in .github/workflows/. In the examples/ directory, there are coding examples that the workflows run on.

Want to contribute? Open up a pull request or an issue! My goal is to have as many languages here as possible so any contribution is welcome.

List of available templates

Language Author(s)
Python sindre0830
Golang sindre0830
Node / React sindre0830
CMake / C++ sindre0830
Rust sindre0830
Gradle / Java MikAoJK

Base layout

Base workflow layout for every programming language:

name: Name of workflow
# when to run the workflow
on:
  push:
    ...
  pull_request:
  workflow_dispatch:
# instructions the workflow will perform
jobs:
  build:
    # environment to run on
    runs-on: ubuntu-latest
    # steps to perform
    steps:
    - uses: actions/checkout@v2

    - name: Set up language
      ...

    - name: Install dependencies
      working-directory: path/to/folder
      ...

    - name: Build program
      working-directory: path/to/folder
      ...

    - name: Run tests
      working-directory: path/to/folder
      ...

    - name: Syntax checker
      working-directory: path/to/folder
      ...

Under the section that decides when to run the workflow you can decide on specific paths. Below you can see an example where the workflow will only run when changes is pushed to the path/to/file/main.py file or when anything changes in the path/to/folder/ directory. This limits the amount of time the workflow is run and helps with reducing the time it takes to get the results. It is recommended to add the workflow file to this list as it triggers the workflow to run on any changes you apply to it, testing the workflow instantly.

Pull requests aren't set to any specific path since it's recommended to run every workflow before merging the branch with main. This reduces the likelihood of mistakes being pushed to the main branch.

The last trigger is the workflow_dispatch. This allows for a manual trigger of the workflow on the branch of your wish. You should get the option under the action page of the workflow.

on:
  push:
    paths:
    - 'path/to/file/main.py'
    - 'path/to/folder/**'
  pull_request:

Under the section that is named set up language you decide the programming language that is relevant for the workflow. Below you have an example with Python. The Python version needs to be changed to whats relevant to your needs.

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.9.10'

The rest of the steps are all different depending on the language. The step running the tests might not be relevant for each workflow so might not be present. You can change the path in the working directory to . if you wish to work in the root directory.

workflow-templates's People

Contributors

sindre0830 avatar mikaojk avatar

Stargazers

Ads Dawson avatar Andrew Johnson avatar Asgeir Storesund Nilsen avatar Stefano Pompei avatar Xaxeric avatar Abdulkareem Ojerinde avatar Ján Bočínec avatar Alvaro Almendros Gala avatar Van Paul Dayag avatar Jared Van Valkengoed avatar Can Evgin avatar  avatar  avatar

Watchers

 avatar

workflow-templates's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.