GitHub action best practics

Github action makes it easier to build test and deploy your project on any platform. In this article, we would look into a few Github action best practices on running a hosted runner.
By following these best practices would not only improve the speed of our workflow run time also save our billing :).
let’s look into these steps
- Caching dependencies to speed up our workflow by - using: actions/cache@v2. This helps save those extra minutes. Find more detail https://github.com/actions/cache. Let’s look at an example
- name: Cache multiple paths
uses: actions/cache@v2
with:
path: |
~/cache
!~/cache/exclude
**/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
2. The maximum number of minutes to let a job run before GitHub automatically cancels it. Default: 360. Time is the money it is literally true if you are running your Github action workflow in hosted running as Gitub would charge you for the duration of your workflow run.
During our last few month's observation, we found some time the workflow runs more than an hour before it stops abnormally while we are not sure what really causes this issue is important to have an expected timeout before the end of our workflow. We can found more information here.
my-job:
runs-on: ubuntu-latest
timeout-minutes: 30
3. We would have to make sure not to commit raw secrets inside our workflow file. Always use secrets stores like Github secret. This is the best place to store and use the credential. To find more information can be found here.

4. Validate and run your newly created or updated workflow file using https://github.com/nektos/act or similar tools for quick confirmation.