forked from rycus86/docker-pycharm
-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (83 loc) · 3.26 KB
/
docker-publish.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
87
88
89
90
91
92
93
94
name: Docker
on:
pull_request:
push:
branches:
- master
env:
# The fully qualified image name of the image to build. The first component is
# the host name of the registry that primarily hosts the image.
#
azul_docker_pycharm_image: docker.io/ucscgi/azul-pycharm
# An optional prefix for the image name if the image is to be pushed to an
# alternate registry instead of the one noted in the image name above.
#
azul_docker_registry: ""
# The tag of the image that's used as the base for this image. Because this
# value isn't reflected in the tag for this image, you also need to bump the
# internal version below when changing this variable.
#
azul_docker_pycharm_base_image_tag: bullseye-20240311
# The version of PyCharm to install in this image.
#
azul_docker_pycharm_upstream_version: 2023.3.5
# The version of this image. The image will be tagged with the version of the
# upstream image followed by the value of this variable. Increment this value
# to update the OS packages installed in the image.
#
azul_docker_pycharm_internal_version: 17
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# To facilitate local builds using the Makefile
driver-opts: ${{ startsWith(env.azul_docker_registry, 'localhost:') && 'network=host' || '' }}
- name: Log into registry
if: >
github.event_name != 'pull_request'
&& vars.AZUL_DOCKER_REGISTRY_USER
uses: docker/login-action@v3
with:
username: ${{ vars.AZUL_DOCKER_REGISTRY_USER }}
password: ${{ secrets.AZUL_DOCKER_REGISTRY_PASSWORD }}
- name: Build and conditionally push Docker image
uses: docker/build-push-action@v5
with:
build-args: |
azul_docker_pycharm_base_image_tag=${{ env.azul_docker_pycharm_base_image_tag }}
azul_docker_pycharm_upstream_version=${{ env.azul_docker_pycharm_upstream_version }}
azul_docker_pycharm_internal_version=${{ env.azul_docker_pycharm_internal_version }}
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: "${{ format(
'{0}{1}:{2}-{3}',
env.azul_docker_registry,
env.azul_docker_pycharm_image,
env.azul_docker_pycharm_upstream_version,
env.azul_docker_pycharm_internal_version
) }}"
cache-from: "${{ format(
'type=registry,ref={0}{1}_buildcache',
env.azul_docker_registry,
env.azul_docker_pycharm_image
) }}"
# The value after '&&' in a ternary operator must be truthy, and since
# an empty string is falsy, we use ' ' instead.
cache-to: "${{ github.event_name == 'pull_request' && ' ' || format(
'type=registry,ref={0}{1}_buildcache,mode=max',
env.azul_docker_registry,
env.azul_docker_pycharm_image
) }}"