Created
April 13, 2022 15:11
-
-
Save ivandotv/8ccb1a65f56166fda39d7ef26152d23d to your computer and use it in GitHub Desktop.
github actions docker pull image if not cached
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: Test | |
on: | |
push: | |
branches: | |
- '*' | |
pull_request: | |
branches: | |
- main | |
- develop | |
jobs: | |
build: | |
name: Node unit tests | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_TAG: mongo:5.0.7 | |
strategy: | |
matrix: | |
# node: ['12', '14', '16'] | |
node: ['16'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Cache .pnpm-store | |
uses: actions/cache@v2 | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Setup node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Install dependencies | |
uses: pnpm/action-setup@v2.2.1 | |
with: | |
version: 6.23.6 | |
run_install: true | |
- name: Container Mongo cache | |
id: mongo-cache | |
uses: actions/cache@v2 | |
with: | |
path: ~/mongo-cache | |
key: mongo-cache-${{ runner.os }}-${{env.IMAGE_TAG}} | |
- if: steps.mongo-cache.outputs.cache-hit != 'true' | |
run: | | |
docker pull $IMAGE_TAG | |
mkdir -p ~/mongo-cache | |
docker save -o ~/mongo-cache/mongo.tar $IMAGE_TAG | |
- if: steps.mongo-cache.outputs.cache-hit == 'true' | |
run: docker load -i ~/mongo-cache/mongo.tar | |
- name: Run tests | |
run: | | |
pnpm test:ci | |
env: | |
CI: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment