runs using node20 #202
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
delete: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20.x | |
- uses: actions/checkout@v3 | |
- name: Output info | |
id: info | |
run: | | |
if [ '${{ github.event_name }}' = 'pull_request' ]; then | |
echo "commit_message=" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
echo "commit_message=[auto]" >> $GITHUB_OUTPUT | |
- uses: jpribyl/[email protected] | |
with: | |
commit-message: ${{ steps.info.outputs.commit_message }} | |
push-branch: '{branch}-release' | |
- uses: actions/upload-artifact@v3 | |
if: github.event_name != 'delete' | |
with: | |
name: built | |
path: ./ | |
- name: Output matrix | |
id: set_matrix | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
return { | |
inspect_image: [ | |
'test_project_scratch', | |
'hello-world', | |
'nothing' | |
], | |
os: [ | |
'ubuntu-latest', | |
'windows-latest', | |
], | |
include: [ | |
{ | |
inspect_image: 'test_project_scratch', | |
prepare_command: 'docker-compose -f test_project/docker-compose.yml -p test_project pull', | |
build_command: 'docker-compose -f test_project/docker-compose.yml -p test_project build', | |
}, { | |
inspect_image: 'hello-world', | |
prepare_command: ':', | |
build_command: 'docker pull hello-world', | |
}, { | |
inspect_image: 'nothing', | |
os: 'ubuntu-latest', | |
prepare_command: 'docker tag node:16 nothing', | |
build_command: ':', | |
}, { | |
inspect_image: 'nothing', | |
os: 'windows-latest', | |
prepare_command: 'docker pull mcr.microsoft.com/windows/nanoserver:1809; docker tag mcr.microsoft.com/windows/nanoserver:1809 nothing', | |
build_command: ':', | |
}, { | |
branch: process.env.GITHUB_REF.replace('refs/heads/', '') | |
} | |
], | |
exclude: [ | |
{ | |
inspect_image: 'test_project_scratch', | |
os: 'windows-latest', | |
}, | |
], | |
} | |
outputs: | |
matrix: ${{ steps.set_matrix.outputs.result }} | |
test_saving: | |
if: github.event_name != 'delete' | |
needs: build | |
strategy: | |
matrix: ${{ fromJSON(needs.build.outputs.matrix) }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- run: ${{ matrix.prepare_command }} | |
- name: Download action | |
uses: actions/download-artifact@v3 | |
with: | |
name: built | |
path: action-dlc | |
- uses: ./action-dlc | |
name: Run jpribyl/action-docker-layer-caching@${{ matrix.branch }} | |
with: | |
key: docker-layer-caching-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash} | |
- run: ${{ matrix.build_command }} | |
test_restoring: | |
needs: [build, test_saving] | |
strategy: | |
matrix: ${{ fromJSON(needs.build.outputs.matrix) }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- run: ${{ matrix.prepare_command }} | |
- name: Extract | |
id: extract | |
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
- name: Download action | |
uses: actions/download-artifact@v3 | |
with: | |
name: built | |
path: action-dlc | |
- uses: ./action-dlc | |
name: Run jpribyl/action-docker-layer-caching@${{ matrix.branch }} | |
with: | |
key: never-restored-docker-layer-caching-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash} | |
restore-keys: docker-layer-caching-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}- | |
skip-save: 'true' | |
- name: Show cached image info | |
run: docker inspect ${{ matrix.inspect_image }} | |
- name: Get cached image ID | |
run: echo id=$(docker image ls -q ${{ matrix.inspect_image }}) >> $GITHUB_OUTPUT | |
id: cached | |
- run: ${{ matrix.build_command }} | |
- name: Show built image info | |
run: docker inspect ${{ matrix.inspect_image }} | |
- name: Show built image ID | |
run: echo id=$(docker image ls -q ${{ matrix.inspect_image }}) >> $GITHUB_OUTPUT | |
id: latest | |
- name: Compare cached ID and after build ID | |
run: | | |
if [ ! '${{ steps.cached.outputs.id }}' = '${{ steps.latest.outputs.id }}' ];then | |
echo cached != latest | |
exit 1 | |
fi |