-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (55 loc) · 1.87 KB
/
ci.yml
File metadata and controls
62 lines (55 loc) · 1.87 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
61
62
on:
push:
branches-ignore:
- "gh-readonly-queue/**"
pull_request:
merge_group:
workflow_dispatch:
schedule:
- cron: "38 3 * * *"
name: Osiris Hardware CI Container Images
env:
TERM: xterm-256color
jobs:
container:
name: Build Container
runs-on: ubuntu-latest
permissions:
packages: write
outputs:
container_name: ${{ steps.set_output.outputs.container_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set container name as output
id: set_output
run: |
BRANCH=$(echo "${GITHUB_REF}" | sed 's|refs/heads/||' | tr '[:upper:]' '[:lower:]')
REPO=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
if [ "$BRANCH" = "main" ]; then
TAG="latest"
else
TAG="${BRANCH//\//-}"
fi
CONTAINER_NAME="ghcr.io/${REPO}:${TAG}"
echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT
echo "container_without_tag=ghcr.io/${REPO}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
file: Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.set_output.outputs.container_name }}
cache-from: |
type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache
type=registry,ref=${{ steps.set_output.outputs.container_without_tag }}:latest-cache
cache-to: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache,mode=max