diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b833b49 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 HeroDevs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3cf4411 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# Shareable Github Actions + +The actions defined in this repository can be reused across all of the NES github organization. + +- [Init](#init) +- [Cache](#cache) +- [Uncache](#uncache) + +## Init + +This action will: + +- authenticate with github +- checkout the code from the repo +- initialize node + +``` +- name: init + uses: neverendingsupport/actions/init@v1 + with: + node-version: 18 +``` + +## Cache + +### Inputs + +`job` - The name of the current job in which you wish to cache +NOTE - this is used to build the key name of the cache being created + +### Usage +``` +- name: cache + uses: neverendingsupport/actions/cache@v1 + with: + job: [JOB_NAME] +``` + +## Uncache + +### Inputs + +`job-name` - The name of the job in which you wish to restore from. + +### Usage +``` +- name: uncache + uses: neverendingsupport/actions/uncache@v1 + with: + from-job: [JOB_NAME] +``` \ No newline at end of file diff --git a/cache/action.yml b/cache/action.yml new file mode 100644 index 0000000..7f7b519 --- /dev/null +++ b/cache/action.yml @@ -0,0 +1,15 @@ +name: 'Cache' +description: 'Cache the workspace' +inputs: + job: + description: 'job name' + required: true + +runs: + using: 'composite' + steps: + - name: save full cache + uses: actions/cache/save@v3 + with: + path: '.' + key: ${{ github.ref_name }}-${{ inputs.job }}-${{ github.run_id }} \ No newline at end of file diff --git a/init/action.yml b/init/action.yml new file mode 100644 index 0000000..a1a328d --- /dev/null +++ b/init/action.yml @@ -0,0 +1,29 @@ +name: 'Initialize' +description: 'Initialize the workspace (checkout, auth, setup node)' +inputs: + node-version: + description: 'The version of node to use (default: 20)' + required: false + default: 20 + +runs: + using: 'composite' + steps: + # Checkout/get the latest code + - uses: actions/checkout@v3 + + # Authenticate + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Set up node with the specified version + - uses: actions/setup-node@v3 v${{ inputs.node-version }} + with: + node-version: ${{ inputs.node-version }} + registry-url: https://npm.pkg.github.com + scope: "@neverendingsupport" + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/uncache/action.yml b/uncache/action.yml new file mode 100644 index 0000000..fa2b7f1 --- /dev/null +++ b/uncache/action.yml @@ -0,0 +1,15 @@ +name: 'Uncache' +description: 'Uncaches the workspace' +inputs: + from-job: + description: 'job name to restore from' + required: true + +runs: + using: 'composite' + steps: + - name: restore full cache + uses: actions/cache/restore@v3 + with: + path: '.' + key: ${{ github.ref_name }}-${{ inputs.from-job }}-${{ github.run_id }} \ No newline at end of file