-
Notifications
You must be signed in to change notification settings - Fork 38
60 lines (52 loc) · 2.15 KB
/
container.yml
File metadata and controls
60 lines (52 loc) · 2.15 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@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Container Metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
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@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
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@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: tutorial-container
path: /tmp/tutorial-container.tar
retention-days: 1
compression-level: 9