-
Notifications
You must be signed in to change notification settings - Fork 6
90 lines (80 loc) · 3.22 KB
/
build-image.yaml
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# This GitHub workflow builds and pushes a user environment image to be used at
# hub.jupytearth.org. After having built the image, administrators can visit
# https://hub.jupytearth.org/services/configurator/ and set the image
#
name: Build image for hub.jupytearth.org
on:
pull_request:
paths:
- .github/workflows/build-image.yaml
- hub.jupytearth.org-image/**
- "!hub.jupytearth.org-image/README.md"
push:
paths:
- .github/workflows/build-image.yaml
- hub.jupytearth.org-image/**
- "!hub.jupytearth.org-image/README.md"
workflow_dispatch:
jobs:
build-image:
name: Build image
runs-on: ubuntu-20.04
steps:
- name: Checkout files in repo
uses: actions/checkout@v2
# Without this we can run out of disk space.
#
# NOTE: This logic is copy pasted from a github action that started to
# error due to an unrelated issue. If we need to update this logic,
# see the following origin of the source code:
# https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L96-L106
#
# NOTE: Removes pre-installed .NET, Android, and Haskell things
#
- name: Maximize build space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
- name: Test build image
run: |
docker build -t image-build-test ./hub.jupytearth.org-image
# ref: https://github.com/aws-actions/configure-aws-credentials
#
- name: Configure AWS credentials
if: github.event_name != 'pull_request'
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ci-ecr
role-skip-session-tagging: true
role-duration-seconds: 3600
# ref: https://github.com/aws-actions/amazon-ecr-login
#
- name: Login to Amazon ECR
if: github.event_name != 'pull_request'
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
if: github.event_name != 'pull_request'
id: push
run: |
IMAGE_NAME=${{ steps.login-ecr.outputs.registry }}/jmte/user-env
IMAGE_TAG=$(git rev-parse --short "$GITHUB_SHA")
IMAGE=$IMAGE_NAME:$IMAGE_TAG
echo ::set-output "name=image-name::$IMAGE"
docker tag image-build-test $IMAGE
docker tag image-build-test $IMAGE_NAME:latest
docker push $IMAGE
docker push $IMAGE_NAME:latest
# NOTE: This manual step is disabled as we are now configured to use the
# :latest image by default so we don't need to do this.
#
# - name: How to update hub.jupytearth.org to use this image
# if: github.event_name != 'pull_request'
# run: |
# echo "1. Visit https://hub.jupytearth.org/services/configurator/ as a JupyterHub admin."
# echo "2. Configure to use this image: ${{ steps.push.outputs.image-name }}"
# echo "3. Press save."