From 4f1a542c747c7c66f6144119ae1b670fce726b02 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sun, 26 Jan 2025 17:44:32 +0100 Subject: [PATCH 1/5] feat: add description in package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 137a0a5..bf0e50a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "github-actions-playground", + "description": "Playground to learn and save all github-actions template I use on my open source projects.", "version": "0.0.0", "packageManager": "yarn@4.6.0", "scripts": { From b62578da708b50108c4ec012a136a6277f828cd8 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sun, 26 Jan 2025 17:44:45 +0100 Subject: [PATCH 2/5] feat: remove --dry-run flag from release script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf0e50a..5a610e1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "packageManager": "yarn@4.6.0", "scripts": { - "release": "release-it --dry-run", + "release": "release-it", "build": "tsc", "lint": "eslint ./src" }, From 45b78200ab44e7d62a922a85b4bb62dc8a7ba0e5 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sun, 26 Jan 2025 17:50:48 +0100 Subject: [PATCH 3/5] chore: improve readme --- README.md | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index ebd84ef..6bbd538 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,26 @@ -# github-actions-playground -This repository is used as a playground to learn and mess with github actions. +# Github Actions Playground -## Notes +In this repository you can find templates and examples of some github actions workflows that I use in my own projects. +They are mainly focused around Typescript and React Native projects, because that's what I work with most of the time. -A basic workflow is configured as follows: +Feel free to copy them and use them in your own projects. -```yaml +## Contributing -name: CI +Contributions are welcome! If you have a workflow that you think is useful and you want to share it, feel free to open a +pull request. -on: [push] +## Workflows -jobs: - build: - name: Build - runs-on: ubuntu-latest +### Release with [release-it](https://github.com/release-it/release-it) - steps: - - name: SayHi - run: echo "Hello, ${{ github.actor }}" +This workflow is triggered manually and can bypass the ruleset that blocks any push to the main branch. It does it by +using a Github App that has been added to the bypass list in the branch protection rules. +Take a look at the [release-it-setup](./docs/release-it-setup.md) document to see how to set it up and an alternative +approach to the bypass procedure. -``` +### Useful links -Each job runs in a fresh instance of the virtual environment, this means that we need to checkout the branch and install -the dependencies in each job; +- [Github Actions Documentation](https://docs.github.com/en/actions) -Continuos Integration (CI): is the practice of automating the integration of code changes from multiple contributors -into a single software project. The CI process is comprised of automatic tools that assert the new code’s correctness -before integration. This means that you can set up github actions to run tests, linters, etc. on each push to the -repository or on a pull request. -Continuous Deployment (CD): is the practice of automating the deployment of code changes to a production environment. -This means that you can set up github actions to deploy your code to a server, a cloud provider, etc. once you are -ready to release a new version of your software. - -By default, github actions have got the GITHUB_TOKEN secret, which is a token that allows the action to interact with the -github API. This token is automatically created by github and is available to all actions. You can use this token to -create issues, pull requests, etc. from your actions. -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 -the worflow file using the `permissions` key. From c1ae7ad03c83ed476f08c7f3daf336c32d1b1d6d Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sun, 26 Jan 2025 17:55:26 +0100 Subject: [PATCH 4/5] feat: create pass-artifacts-to-next-jobs doc --- docs/pass-artifacts-to-next-jobs.md | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 docs/pass-artifacts-to-next-jobs.md diff --git a/docs/pass-artifacts-to-next-jobs.md b/docs/pass-artifacts-to-next-jobs.md new file mode 100644 index 0000000..d948ec2 --- /dev/null +++ b/docs/pass-artifacts-to-next-jobs.md @@ -0,0 +1,63 @@ +# Pass artifacts to next jobs + +When you have a workflow with multiple jobs and you need to pass artifacts (products) from one job to the next ones, +you can use the `needs` keyword and a couple of actions from the GitHub Marketplace. + +The `needs` keyword allows you sequence the jobs in a workflow. You can specify that a job can only run after another +job has completed successfully. This is required when you need to pass artifacts from one job to another. + +To actually pass the artificats, you can use the `upload-artifact` and `download-artifact` actions from the GitHub +Marketplace. The `upload-artifact` action allows you to upload a file or directory as an artifact. The `download-artifact` +action allows you to download an artifact from a previous job. + +Take a look at the following example: + +```yaml + +name: pass-artifacts-to-next-jobs + +on: workflow_dispatch + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - name: Build + run: yarn build + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: build-artifact + path: build + + run-build: + name: Run build + runs-on: ubuntu-latest + needs: build + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - name: Download Build Artifact + uses: actions/download-artifact@v4 + with: + name: build-artifact + + - name: Run + # This assumes that your build artifacts is an index.js + run: node index.js + +``` From 11996842acca3f09e4b1fa00b83e51e69fc1a169 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Sun, 26 Jan 2025 17:56:48 +0100 Subject: [PATCH 5/5] chore: update readme with pass artifacts to next jobs --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6bbd538..82b7e54 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,12 @@ using a Github App that has been added to the bypass list in the branch protecti Take a look at the [release-it-setup](./docs/release-it-setup.md) document to see how to set it up and an alternative approach to the bypass procedure. -### Useful links +### Pass artifacts to next jobs + +This workflow shows how to pass artifacts from one job to another. +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. + +## Useful links - [Github Actions Documentation](https://docs.github.com/en/actions)