forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (45 loc) · 2.12 KB
/
docker.yml
File metadata and controls
52 lines (45 loc) · 2.12 KB
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
#
name: Build Docker image and push to GitHub Packages
# This workflow file is adapted from the example at https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token
on:
push:
branches:
- main
# Only rebuild if the Dockerfile or dependencies change.
paths:
- '.devcontainer/**'
- 'python/servo/platform/linux_packages/**'
workflow_dispatch:
jobs:
devcontainer_ubuntu:
runs-on: ubuntu-latest
# We probably don't want to spam the package registry of every developer
# thats working on servo and has actions enabled on their fork.
# You can comment this if to test changes to the workflow locally in your fork,
# use manual workflow dispatch in your fork.
if: github.repository_owner == 'servo' || github.event_name == 'workflow_dispatch'
permissions:
packages: write
contents: read
env:
IMAGE_NAME: devcontainer-ubuntu
steps:
- uses: actions/checkout@v6
- name: Build image
run: docker build . --file .devcontainer/Ubuntu.Dockerfile --tag ${{ env.IMAGE_NAME }} --label "runnumber=${GITHUB_RUN_ID}"
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/servo/$IMAGE_NAME
# This changes all uppercase characters to lowercase.
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
# Todo: It would be nice to add another tag here, that has a version number, or a date-tag.
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION