-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial attempt at ubuntu image build workflow (#4)
- Loading branch information
1 parent
e151c64
commit 34339e3
Showing
2 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Build and push Ubuntu image | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
paths: | ||
- ubuntu/** | ||
schedule: | ||
- cron: "0 0 * * 1" # Every Monday at 00:00 | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: docker.io | ||
IMAGE_OWNER: glitchcrab | ||
IMAGE_NAME: ubuntu-debug | ||
|
||
jobs: | ||
debug_info: | ||
name: Debug info | ||
runs-on: self-hosted | ||
steps: | ||
- name: Print github context JSON | ||
run: | | ||
cat <<EOF | ||
${{ toJson(github) }} | ||
EOF | ||
build-on-push-trigger: | ||
runs-on: self-hosted | ||
if: github.event_name == 'push' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ env.IMAGE_OWNER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN_UBUNTU }} | ||
|
||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=semver,pattern={{raw}} | ||
type=schedule,pattern={{date 'YYYYMMDD'}} | ||
type=raw,value=latest | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: "./ubuntu" | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
build-on-any-other-trigger: | ||
runs-on: self-hosted | ||
if: github.event_name != 'push' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ env.IMAGE_OWNER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN_UBUNTU }} | ||
|
||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=schedule,pattern={{date 'YYYYMMDD'}} | ||
type=raw,value=latest | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: "./ubuntu" | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters