Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add a simple workflow to get started with GitHub Actions #27

Merged
merged 1 commit into from
Aug 3, 2020

Conversation

localheinz
Copy link
Contributor

@localheinz localheinz commented Aug 3, 2020

This PR

  • adds a very simple workflow to get started with GitHub Actions

πŸ’β€β™‚οΈ This is part 1 of a series of pull requests, as suggested here:

Copy link
Contributor Author

@localheinz localheinz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see in the Checks tab, a workflow has not been triggered.

This is because the workflow was added from a fork, and a workflow does not exist in the repository yet.

In case you accept this pull request, a workflow will run on the merge commit. Subsequent changes to the workflow will have an effect once the workflow is available in the default branch.

You can see the workflow running in my fork.

@@ -1,5 +1,6 @@
/.github export-ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding .github here because users of this package probably do not need the contents of the .github directory.

@@ -0,0 +1,19 @@
# https://docs.github.com/en/actions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a reference to the GitHub Actions documentation here so anyone making changes to the workflow file can easily look it up.

@@ -0,0 +1,19 @@
# https://docs.github.com/en/actions

name: Build
Copy link
Contributor Author

@localheinz localheinz Aug 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the name of the workflow as it will appear in the GitHub UI:

  • in the Actions tab of the repository

    Screen Shot 2020-08-03 at 09 07 09

  • in the Checks tab for the pull request
    Screen Shot 2020-08-03 at 09 06 30

  • in the list of status checks for a pull request

    Screen Shot 2020-08-03 at 09 05 19

The name used here will also need to be used when linking to a status badge (see README.md below).

πŸ’β€β™‚οΈ For reference, see


name: Build

on:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using on we can configure a list of events that can trigger a workflow.

πŸ’β€β™‚οΈ For reference, see

name: Build

on:
pull_request: null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listing pull_request here so we run the workflow on default pull_request events.

These events include:

  • opened (a pull request was opened)
  • reopened (a pull request was reopened)
  • synchronize (one or more commits have been pushed into the corresponding branch)

πŸ’β€β™‚οΈ For reference, see

hello:
name: Hello

runs-on: ubuntu-latest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using runs-on we can specify the system on which the job should run.

The system can be one of:

  • ubuntu-16.04
  • ubuntu-18.04 (orΒ ubuntu-latest)
  • ubuntu-20.04
  • ubuntu-latest (orΒ ubuntu-18.04)
  • macos-10.15Β (orΒ macos-latest)
  • macos-latestΒ (orΒ macos-10.15)
  • windows-2019 (or windows-latest)
  • windows-latest (or windows-2019)

πŸ’β€β™‚οΈ For reference, see


runs-on: ubuntu-latest

steps:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each job consists of a series of steps. Every job needs to have at least one step.

πŸ’β€β™‚οΈ For reference, see

runs-on: ubuntu-latest

steps:
- name: Echo a greeting
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A job can have a name, which will then be displayed in the output of the workflow run. The name can be omitted.

It is possible to use variables in the name, they will then be expanded (more on that later).

πŸ’β€β™‚οΈ For reference, see


steps:
- name: Echo a greeting
run: echo 'Hello, GitHub Actions!'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A job can have a run or a uses directive.

With the run directive we can configure one or more commands to run on the command line.

πŸ’β€β™‚οΈ For reference, see

@@ -1,6 +1,7 @@
# Version

[![Build Status](https://travis-ci.com/nikolaposa/version.svg?branch=master)](https://travis-ci.com/nikolaposa/version)
[![Build](/~https://github.com/nikolaposa/version/workflows/Build/badge.svg?branch=master)](/~https://github.com/nikolaposa/version/actions)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a badge here.

Note that Build in the URL refers to the name of the workflow. When the name of the workflow contained spaces, they would need to be URL-encoded.

For example:

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 958cb47..aa1a9dc 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -1,6 +1,6 @@
 # https://docs.github.com/en/actions

-name: Build
+name: Continuous Integration

 on:
   pull_request: null
diff --git a/README.md b/README.md
index 7ed172e..f4d7ca8 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 # Version

 [![Build Status](https://travis-ci.com/nikolaposa/version.svg?branch=master)](https://travis-ci.com/nikolaposa/version)
-[![Build](/~https://github.com/nikolaposa/version/workflows/Build/badge.svg?branch=master)](/~https://github.com/nikolaposa/version/actions)
+[![Build](/~https://github.com/nikolaposa/version/workflows/Continous%20Integration/badge.svg?branch=master)](/~https://github.com/nikolaposa/version/actions)
 [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nikolaposa/version/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nikolaposa/version/?branch=master)
 [![Code Coverage](https://scrutinizer-ci.com/g/nikolaposa/version/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/nikolaposa/version/?branch=master)
 [![Latest Stable Version](https://poser.pugx.org/nikolaposa/version/v/stable)](https://packagist.org/packages/nikolaposa/version)

@localheinz localheinz marked this pull request as ready for review August 3, 2020 07:08
@nikolaposa nikolaposa self-assigned this Aug 3, 2020
@nikolaposa nikolaposa self-requested a review August 3, 2020 08:11
Copy link
Owner

@nikolaposa nikolaposa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like where this is going, thank you very much for willing to contribute and putting effort into this work. πŸ‘ I can already see benefits of moving to GitHub Actions, the most obvious is more natural "Checks" tab.

@localheinz
Copy link
Contributor Author

@nikolaposa

I am glad you like it! I'm prepared to follow up, as promised! πŸ€“

@nikolaposa
Copy link
Owner

@localheinz Thanks!

So what do you think should be the next steps? I suppose this was a PR with demonstrative purposes, do you think we should merge it anyway?

@localheinz
Copy link
Contributor Author

@nikolaposa

πŸ‘ Let's merge it, and then I will follow up!

@nikolaposa nikolaposa merged commit 2c67077 into nikolaposa:master Aug 3, 2020
@localheinz
Copy link
Contributor Author

Thank you, @nikolaposa!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants