This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
86 lines (75 loc) · 2.72 KB
/
docker.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
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
name: Build and publish Docker image
on:
push:
branches:
- main
release:
types: [published]
branches: [main]
env:
IMAGE_NAME: doctools-builder
IMAGE_LATEST_TAG: latest
REGISTRY: ghcr.io
jobs:
publish_docker:
name: Build and push Docker image
if: github.event.repository.fork == false
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Set image ID and TAG
shell: sh
id: generate_image_info
run: |
IMAGE_ID=$REGISTRY/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# output image id
echo "::set-output name=id::$IMAGE_ID"
# output image tag
echo "::set-output name=tag::${GITHUB_REF#refs/*/}"
- name: Build image
shell: sh
run: |
docker build . \
--tag $IMAGE_NAME \
--build-arg VERSION="${{ steps.generate_image_info.outputs.tag }}" \
--build-arg REVISION="${GITHUB_SHA}" \
--build-arg GITHUB_WORKFLOW="${GITHUB_WORKFLOW}" \
--build-arg GITHUB_RUN_ID="${GITHUB_RUN_ID}"
- name: Image minimal test
shell: sh
run: |
docker run --rm \
-e VERSION=test \
-v ${PWD}:/workspace \
-w /workspace \
$IMAGE_NAME \
build -s \
--config-file /workspace/tests/mkdocs.yml
- name: Login to GitHub Container Registry
#https://github.com/docker/login-action/releases/tag/v1.10.0
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push latest
shell: sh
run: |
docker tag $IMAGE_NAME ${{ steps.generate_image_info.outputs.id }}:$IMAGE_LATEST_TAG
docker push ${{ steps.generate_image_info.outputs.id }}:$IMAGE_LATEST_TAG
- name: Push tagged release
if: github.event_name == 'release' && github.event.action == 'published'
shell: sh
run: |
docker tag $IMAGE_NAME ${{ steps.generate_image_info.outputs.id }}:${{ steps.generate_image_info.outputs.tag }}
docker push ${{ steps.generate_image_info.outputs.id }}:${{ steps.generate_image_info.outputs.tag }}
- name: Test building doc using our action
uses: ConsenSys/doctools.action-builder/actions/build@main
with:
SITE_ROOT: 'https://example.org' #fake site, just testing but cannot be empty
MKDOCS_CONFIG: /workspace/tests/mkdocs.yml