-
Notifications
You must be signed in to change notification settings - Fork 1
40 lines (34 loc) · 1.27 KB
/
devcontainer.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
name: Generation Dev Container Base Image
on:
push:
branches:
- 'devcontainer-test'
- 'main'
paths:
- '.devcontainer/base.Dockerfile'
- 'library-scripts/**/*'
jobs:
devcontainer:
name: Generate base image
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v2
- name: Build and push dev container base image
id: build_and_push
run: |
set -e
CONTAINER_IMAGE_REGISTRY=ghcr.io
REPOSITORY_PATH=codespaces-contrib/demo/dependency-caching
IMAGE_REPOSITORY="${CONTAINER_IMAGE_REGISTRY}/${REPOSITORY_PATH}"
echo "${{ secrets.GHCR_PAT }}" | docker login ${CONTAINER_IMAGE_REGISTRY} -u "${{ secrets.GHCR_USER }}" --password-stdin
cd .devcontainer
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
BRANCH_TAG="base-${BRANCH//\//-}"
docker build -t "${IMAGE_REPOSITORY}:${BRANCH_TAG}" -f "base.Dockerfile" .
docker push "${IMAGE_REPOSITORY}:${BRANCH_TAG}"
if [ "${BRANCH}" = "master" ] || [ "${BRANCH}" = "main" ]; then
docker tag "${IMAGE_REPOSITORY}:${BRANCH_TAG}" "${IMAGE_REPOSITORY}:latest"
docker push "${IMAGE_REPOSITORY}:latest"
fi