Skip to content

Commit 5cf2c41

Browse files
authored
Create main.yml GitHub Action
1 parent bcbc129 commit 5cf2c41

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/main.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Docker Image Generation
2+
3+
on:
4+
# Triggers the workflow on push or pull request events for specific branches
5+
push:
6+
branches: [ dockerize ]
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
19+
- uses: actions/checkout@v3
20+
# Fetch all history for all tags and branches
21+
with:
22+
fetch-depth: 0
23+
24+
- name: checkout rfsoc-streamer
25+
uses: actions/checkout@v3
26+
with:
27+
repository: ccatobs/rfsoc-streamer
28+
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
# Set up Docker Buildx
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v2
39+
40+
# Add Docker layer caching
41+
- name: Cache Docker layers
42+
uses: actions/cache@v3
43+
with:
44+
path: /tmp/.buildx-cache
45+
key: ${{ runner.os }}-buildx-${{ github.sha }}
46+
restore-keys: |
47+
${{ runner.os }}-buildx-
48+
- name: Extract metadata (tags, labels) for Docker
49+
id: meta
50+
uses: docker/metadata-action@v4
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
54+
- name: Build and push Docker image
55+
uses: docker/build-push-action@v4
56+
with:
57+
context: .
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
builder: ${{ steps.buildx.outputs.name }}
62+
cache-from: type=local,src=/tmp/.buildx-cache
63+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
64+
65+
# Temp fix for cache size growth
66+
- name: Move cache
67+
run: |
68+
rm -rf /tmp/.buildx-cache
69+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 commit comments

Comments
 (0)