-
Notifications
You must be signed in to change notification settings - Fork 38
60 lines (52 loc) · 2.21 KB
/
Copy pathcontainer.yml
File metadata and controls
60 lines (52 loc) · 2.21 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
53
54
55
56
57
58
59
60
name: Build Tutorial Container
on:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v3.0.0
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Container Metadata
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v5.0.0
id: metadata
with:
images: ghcr.io/spack/tutorial
tags: |
# set latest tag for default branch
type=raw,value=latest
# set tag if spawned by a tag
type=raw,value={{tag}}
- name: Build & Push
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v5.0.0
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
with:
context: "{{defaultContext}}:container"
platforms: linux/amd64
tags: ${{ steps.metadata.outputs.tags }}
cache-from: type=registry,ref=ghcr.io/spack/tutorial:buildcache
cache-to: ${{ github.ref_name == github.event.repository.default_branch
&& 'type=registry,ref=ghcr.io/spack/tutorial:buildcache,mode=max' || '' }}
outputs: ${{ (github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/'))
&& 'type=registry' || 'type=docker,dest=/tmp/tutorial-container.tar' }}
- name: Upload container as artifact for PRs
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4.3.1
with:
name: tutorial-container
path: /tmp/tutorial-container.tar
retention-days: 1
compression-level: 9