| 1 |
name: Docker Build |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- master |
| 7 |
|
| 8 |
permissions: |
| 9 |
contents: read |
| 10 |
|
| 11 |
jobs: |
| 12 |
build: |
| 13 |
permissions: |
| 14 |
packages: write |
| 15 |
runs-on: ubuntu-20.04 |
| 16 |
steps: |
| 17 |
- name: Harden Runner |
| 18 |
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 |
| 19 |
with: |
| 20 |
egress-policy: audit |
| 21 |
|
| 22 |
- name: Get current time |
| 23 |
uses: 1466587594/get-current-time@060cae3fbd32c181c6841788189a601ac8df8389 # v2.1.2 |
| 24 |
id: current-time |
| 25 |
with: |
| 26 |
format: YYYY-MM-DD--HH |
| 27 |
|
| 28 |
- name: Checkout code |
| 29 |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 30 |
with: |
| 31 |
submodules: recursive |
| 32 |
|
| 33 |
- name: Set up QEMU |
| 34 |
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 |
| 35 |
|
| 36 |
- name: Set up Docker Buildx |
| 37 |
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 |
| 38 |
|
| 39 |
- name: Cache Docker layers |
| 40 |
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 |
| 41 |
with: |
| 42 |
path: /tmp/.buildx-cache |
| 43 |
key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 44 |
restore-keys: | |
| 45 |
${{ runner.os }}-buildx- |
| 46 |
|
| 47 |
- name: Login to DockerHub |
| 48 |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 |
| 49 |
with: |
| 50 |
username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 51 |
password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 52 |
|
| 53 |
- name: Log in to the Container registry |
| 54 |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 |
| 55 |
with: |
| 56 |
registry: ghcr.io |
| 57 |
username: ${{ github.actor }} |
| 58 |
password: ${{ secrets.GITHUB_TOKEN }} |
| 59 |
|
| 60 |
- name: Build and push |
| 61 |
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0 |
| 62 |
with: |
| 63 |
platforms: linux/amd64 |
| 64 |
push: true |
| 65 |
tags: | |
| 66 |
ghcr.io/intel/pcm:latest |
| 67 |
opcm/pcm:latest |
| 68 |
cache-from: type=local,src=/tmp/.buildx-cache |
| 69 |
cache-to: type=local,dest=/tmp/.buildx-cache |