-
Notifications
You must be signed in to change notification settings - Fork 1
42 lines (36 loc) · 1.4 KB
/
devcontainer-cache.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Generate Dev Container Cache Image
on:
push:
# Update this to build images for other branches
branch:
- 'devcontainer-test'
- 'main'
# Update this list of there are other files you want to watch to do cache updates
paths:
- '**/package-lock.json'
- '**/yarn.lock'
jobs:
devcontainer:
name: Generate cache image
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v2
- name: Build and push cache image
id: build_and_push
run: |
set -e
CONTAINER_IMAGE_REGISTRY=ghcr.io
REPOSITORY_PATH=codespaces-contrib/demo/dependency-caching
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
BRANCH_TAG="base-${BRANCH//\//-}"
BASE_IMAGE_ID="${CONTAINER_IMAGE_REGISTRY}/${REPOSITORY_PATH}:${BRANCH_TAG}"
echo "${{ secrets.GHCR_PAT }}" | docker login "${CONTAINER_IMAGE_REGISTRY}" -u "${{ secrets.GHCR_USER }}" --password-stdin
.devcontainer/cache/build-cache-image.sh "${BASE_IMAGE_ID}" "${BASE_IMAGE_ID}" "node" "." "true" "image"
git config --global user.email "[email protected]"
git config --global user.name "CI"
git add .devcontainer/devcontainer.json
git commit -am 'Automated devcontainer.json update' \
&& git push \
|| echo 'No updates to devcontainer.json'