repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

pico / .github / actions / build
Antonio Mika  ·  2023-11-08

action.yml

 1name: Run a docker build
 2
 3description: Runs a docker build in a composite action
 4
 5inputs:
 6  app:
 7    description: The pico app to build
 8    required: true
 9  platforms:
10    description: The docker platforms to build for
11    required: true
12    default: |
13      linux/amd64
14      linux/arm64      
15  registry:
16    description: The docker registry to use
17    required: true
18    default: ghcr.io
19  web:
20    description: Whether or not to build the web image
21    required: true
22    default: true
23    type: boolean
24  ssh:
25    description: Whether or not to build the ssh image
26    required: true
27    default: true
28    type: boolean
29
30runs:
31  using: composite
32  steps:
33    - name: Collect web image metadata
34      id: webmeta
35      uses: docker/metadata-action@v4
36      with:
37        images: ${{ inputs.REGISTRY }}/${{ github.repository }}/${{ inputs.app }}-web
38    - name: Collect ssh image metadata
39      id: sshmeta
40      uses: docker/metadata-action@v4
41      with:
42        images: ${{ inputs.REGISTRY }}/${{ github.repository }}/${{ inputs.app }}-ssh
43    - name: Build and push web
44      if: inputs.web == 'true'
45      uses: docker/build-push-action@v3
46      with:
47        context: .
48        push: true
49        tags: ${{ steps.webmeta.outputs.tags }}
50        labels: ${{ steps.webmeta.outputs.labels }}
51        target: release-web
52        platforms: ${{ inputs.platforms }}
53        cache-from: type=gha
54        cache-to: type=gha,mode=max
55        build-args: |
56          APP=${{ inputs.app }}          
57    - name: Build and push ssh
58      if: inputs.ssh == 'true'
59      uses: docker/build-push-action@v3
60      with:
61        context: .
62        push: true
63        tags: ${{ steps.sshmeta.outputs.tags }}
64        labels: ${{ steps.sshmeta.outputs.labels }}
65        target: release-ssh
66        platforms: ${{ inputs.platforms }}
67        cache-from: type=gha
68        cache-to: type=gha,mode=max
69        build-args: |
70          APP=${{ inputs.app }}