-
Notifications
You must be signed in to change notification settings - Fork 8
83 lines (82 loc) · 2.53 KB
/
setup-environment.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
on:
workflow_call:
inputs:
requirement-file:
description: 'Path to the requirement file.'
required: true
type: string
docker-tag:
description: 'Docker tag for the resulting image.'
required: true
type: string
context:
description: 'Path to the context directory of the Dockerfile.'
required: true
type: string
platforms:
description: 'Platform to build the image for.'
required: false
type: string
default: linux/amd64
ref:
description: 'The ref to checkout.'
required: false
type: string
default: ${{ github.event.pull_request.head.sha }}
install-qemu:
description: 'Install QEmu for cross-platform builds.'
required: false
type: boolean
default: true
copy-requirements:
description: 'Copy the requirements file to the action.'
required: false
type: boolean
default: true
tar-and-copy-root:
description: 'Tar and copy the root directory to the action.'
required: false
type: boolean
default: false
secrets:
DOCKERHUB_USER:
description: 'Dockerhub username.'
required: true
DOCKERHUB_TOKEN:
description: 'Dockerhub token.'
required: true
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Tar and copy root
if: ${{ inputs.tar-and-copy-root }}
run: |
tar --exclude='./.github' -zcf ${{ inputs.context }}/root.tar.gz .
ls -l ${{ inputs.context }}
- name: Copy python requirements to actions
if: ${{ inputs.copy-requirements }}
run: cp ${{ inputs.requirement-file }} ${{ inputs.context }}
- name: Set up QEMU
if: ${{ inputs.install-qemu }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ inputs.context }}
platforms: ${{ inputs.platforms }}
push: true
tags: ${{ inputs.docker-tag }}
cache-from: type=gha
cache-to: type=gha,mode=max