Skip to content

Commit

Permalink
rename steps and composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
shota-kamezawa committed Jun 12, 2023
1 parent ae6a039 commit 57c25b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ env:
jobs:
build:
runs-on: ubuntu-latest
needs: []
outputs:
artifact-name: ${{ steps.define-artifact-name.outputs.VALUE }}
artifact-path: ${{ steps.define-artifact-path.outputs.VALUE }}
artifact-name: ${{ steps.artifact-name.outputs.VALUE }}
artifact-path: ${{ steps.artifact-path.outputs.VALUE }}
steps:
- uses: actions/checkout@v3

Expand All @@ -34,7 +33,7 @@ jobs:
node-version-file: .tool-versions

- id: node-modules-cache-key
uses: ./.github/workflows/composite/define-cache-key-for-node-modules
uses: ./.github/workflows/composite/node-modules-cache-key
with:
node-env: ${{ env.NODE_ENV }}
node-version: ${{ steps.setup-node.outputs.node-version }}
Expand All @@ -51,17 +50,17 @@ jobs:
- run: yarn run build
shell: bash

- id: define-artifact-name
- id: artifact-name
run: echo "VALUE=build-${GITHUB_SHA}" >> $GITHUB_OUTPUT
shell: bash

- id: define-artifact-path
- id: artifact-path
run: echo "VALUE=.output" >> $GITHUB_OUTPUT
shell: bash

- if: ${{ inputs.use-artifact == true }}
uses: actions/upload-artifact@v3
with:
name: ${{ steps.define-artifact-name.outputs.VALUE }}
path: ${{ steps.define-artifact-path.outputs.VALUE }}
name: ${{ steps.artifact-name.outputs.VALUE }}
path: ${{ steps.artifact-path.outputs.VALUE }}
retention-days: 5
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
node-version-file: .tool-versions

- id: node-modules-cache-key
uses: ./.github/workflows/composite/define-cache-key-for-node-modules
uses: ./.github/workflows/composite/node-modules-cache-key
with:
node-env: ${{ env.NODE_ENV }}
node-version: ${{ steps.setup-node.outputs.node-version }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Composite action for node_modules cache key
name: Composite action for actions/cache with node_modules

description: Define cache key for node_modules directory

Expand All @@ -13,19 +13,18 @@ inputs:
outputs:
key:
description: For 'key'
value: ${{ steps.define-key.outputs.VALUE }}
value: ${{ steps.key.outputs.VALUE }}
path:
description: For 'path'
value: node_modules
restore-keys:
description: For 'restore-keys'
value: ${{ steps.define-restore-key.outputs.VALUE }}
value: ${{ steps.restore-key.outputs.VALUE }}

runs:
using: composite

steps:
- id: define-restore-key
- id: restore-key
run: |
NODE_MAJOR=$(echo $NODE_VERSION | cut -f 1 -d .)
echo "VALUE=node-modules-${NODE_MAJOR}-${NODE_ENV}-" >> $GITHUB_OUTPUT
Expand All @@ -34,9 +33,9 @@ runs:
NODE_VERSION: ${{ inputs.node-version }}
shell: bash

- id: define-key
- id: key
run: echo "VALUE=${RESTORE_KEY}${IDENTIFIER}" >> $GITHUB_OUTPUT
env:
RESTORE_KEY: ${{ steps.define-restore-key.outputs.VALUE }}
RESTORE_KEY: ${{ steps.restore-key.outputs.VALUE }}
IDENTIFIER: ${{ hashFiles('yarn.lock') }}
shell: bash

0 comments on commit 57c25b1

Please sign in to comment.