Skip to content

Readme Test

Readme Test #693

Workflow file for this run

name: Readme Test
on:
push:
branches:
- master
schedule:
- cron: 0 0 */3 * *
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Output matrix
id: set_matrix
uses: actions/github-script@v2
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:12 nothing',
build_command: ':',
}, {
inspect_image: 'nothing',
os: 'windows-latest',
prepare_command: '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@v2
- run: ${{ matrix.prepare_command }}
- uses: satackey/action-docker-layer-caching@master-release
with:
key: docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
restore-keys: ''
- 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@v2
- run: ${{ matrix.prepare_command }}
- uses: satackey/action-docker-layer-caching@master-release
with:
key: never-restored-docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
restore-keys: docker-layer-caching-${{ github.workflow }}-${{ 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 ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
id: cached
- run: ${{ matrix.build_command }}
- name: Show built image info
run: docker inspect ${{ matrix.inspect_image }}
- name: Show built image ID
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
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