Skip to content

Commit 42a9261

Browse files
authored
feat: improve repository docs (#3)
* feat: add description in package.json * feat: remove --dry-run flag from release script * chore: improve readme * feat: create pass-artifacts-to-next-jobs doc * chore: update readme with pass artifacts to next jobs
1 parent dbe2705 commit 42a9261

File tree

3 files changed

+84
-30
lines changed

3 files changed

+84
-30
lines changed

README.md

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
1-
# github-actions-playground
2-
This repository is used as a playground to learn and mess with github actions.
1+
# Github Actions Playground
32

4-
## Notes
3+
In this repository you can find templates and examples of some github actions workflows that I use in my own projects.
4+
They are mainly focused around Typescript and React Native projects, because that's what I work with most of the time.
55

6-
A basic workflow is configured as follows:
6+
Feel free to copy them and use them in your own projects.
77

8-
```yaml
8+
## Contributing
99

10-
name: CI
10+
Contributions are welcome! If you have a workflow that you think is useful and you want to share it, feel free to open a
11+
pull request.
1112

12-
on: [push]
13+
## Workflows
1314

14-
jobs:
15-
build:
16-
name: Build
17-
runs-on: ubuntu-latest
15+
### Release with [release-it](https://github.com/release-it/release-it)
1816

19-
steps:
20-
- name: SayHi
21-
run: echo "Hello, ${{ github.actor }}"
17+
This workflow is triggered manually and can bypass the ruleset that blocks any push to the main branch. It does it by
18+
using a Github App that has been added to the bypass list in the branch protection rules.
19+
Take a look at the [release-it-setup](./docs/release-it-setup.md) document to see how to set it up and an alternative
20+
approach to the bypass procedure.
2221

23-
```
22+
### Pass artifacts to next jobs
2423

25-
Each job runs in a fresh instance of the virtual environment, this means that we need to checkout the branch and install
26-
the dependencies in each job;
24+
This workflow shows how to pass artifacts from one job to another.
25+
Take a look at the [pass-artifacts-to-next-job](./docs/pass-artifacts-to-next-jobs.md) document to see how to set it up.
2726

28-
Continuos Integration (CI): is the practice of automating the integration of code changes from multiple contributors
29-
into a single software project. The CI process is comprised of automatic tools that assert the new code’s correctness
30-
before integration. This means that you can set up github actions to run tests, linters, etc. on each push to the
31-
repository or on a pull request.
27+
## Useful links
28+
29+
- [Github Actions Documentation](https://docs.github.com/en/actions)
3230

33-
Continuous Deployment (CD): is the practice of automating the deployment of code changes to a production environment.
34-
This means that you can set up github actions to deploy your code to a server, a cloud provider, etc. once you are
35-
ready to release a new version of your software.
3631

37-
By default, github actions have got the GITHUB_TOKEN secret, which is a token that allows the action to interact with the
38-
github API. This token is automatically created by github and is available to all actions. You can use this token to
39-
create issues, pull requests, etc. from your actions.
40-
If you want to push to the repository tho, you need to update the permissions of the token and you can do it right in
41-
the worflow file using the `permissions` key.

docs/pass-artifacts-to-next-jobs.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Pass artifacts to next jobs
2+
3+
When you have a workflow with multiple jobs and you need to pass artifacts (products) from one job to the next ones,
4+
you can use the `needs` keyword and a couple of actions from the GitHub Marketplace.
5+
6+
The `needs` keyword allows you sequence the jobs in a workflow. You can specify that a job can only run after another
7+
job has completed successfully. This is required when you need to pass artifacts from one job to another.
8+
9+
To actually pass the artificats, you can use the `upload-artifact` and `download-artifact` actions from the GitHub
10+
Marketplace. The `upload-artifact` action allows you to upload a file or directory as an artifact. The `download-artifact`
11+
action allows you to download an artifact from a previous job.
12+
13+
Take a look at the following example:
14+
15+
```yaml
16+
17+
name: pass-artifacts-to-next-jobs
18+
19+
on: workflow_dispatch
20+
21+
jobs:
22+
build:
23+
name: Build
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup
31+
uses: ./.github/actions/setup
32+
33+
- name: Build
34+
run: yarn build
35+
36+
- name: Upload Build Artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: build-artifact
40+
path: build
41+
42+
run-build:
43+
name: Run build
44+
runs-on: ubuntu-latest
45+
needs: build
46+
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
51+
- name: Setup
52+
uses: ./.github/actions/setup
53+
54+
- name: Download Build Artifact
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: build-artifact
58+
59+
- name: Run
60+
# This assumes that your build artifacts is an index.js
61+
run: node index.js
62+
63+
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "github-actions-playground",
3+
"description": "Playground to learn and save all github-actions template I use on my open source projects.",
34
"version": "0.0.0",
45
"packageManager": "yarn@4.6.0",
56
"scripts": {
6-
"release": "release-it --dry-run",
7+
"release": "release-it",
78
"build": "tsc",
89
"lint": "eslint ./src"
910
},

0 commit comments

Comments
 (0)