Skip to content

Commit

Permalink
Refine container actions (#47)
Browse files Browse the repository at this point in the history
* Update redhat actions to Node.js 20 era versions
* Specify hash and commented version style
  * To keep stability
  * To keep dependabot compatibility
* Trigger build phase for each PRs
* Add datetime timestamp as a tag
* Abstract owner the repository owner :)
  • Loading branch information
kachick authored Mar 8, 2024
1 parent f98084f commit 8e4df08
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 39 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Containers
on:
push:
tags:
- 'v*'
branches: [main]
paths:
- '**Containerfile'
- '.containerignore'
- '.github/workflows/containers.yml'
pull_request:
paths:
- '**Containerfile'
- '.containerignore'
- '.github/workflows/containers.yml'
workflow_dispatch:

jobs:
build_and_push:
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- name: Get started timestamp
id: get-meta
run: |
# Do not use ":" delimiter as iso-8601/rfc-3339, it cannot be used in container tag
echo "started_at=$(date --utc '+%Y%m%d-%H%M%S-%Z')" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 #v2.13
with:
image: ubuntu-nix-sudoer
tags: latest ${{ github.sha }} ${{ steps.get-meta.outputs.started_at }}
containerfiles: |
./images/ubuntu-nix-sudoer/Containerfile
build-args: |
username=user
oci: true
- name: Push To ghcr.io
id: push-to-ghcr
if: ${{ github.event_name != 'pull_request' }}
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c #v2.8
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Log outputs
if: ${{ github.event_name != 'pull_request' }}
run: echo "${{ toJSON(steps.push-to-ghcr.outputs) }}"
38 changes: 0 additions & 38 deletions .github/workflows/push-cr.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Containerfile(s)

[![CI - Nix Status](https://github.com/kachick/containers/actions/workflows/ci-nix.yml/badge.svg?branch=main)](https://github.com/kachick/containers/actions/workflows/ci-nix.yml?query=branch%3Amain+)
[![CI - Push Status](https://github.com/kachick/containers/actions/workflows/push-cr.yml/badge.svg?branch=main)](https://github.com/kachick/containers/actions/workflows/push-cr.yml?query=branch%3Amain+)
[![CI - Container Status](https://github.com/kachick/containers/actions/workflows/containers.yml/badge.svg?branch=main)](https://github.com/kachick/containers/actions/workflows/containers.yml?query=branch%3Amain+)

Usage is written in README.md in each images directory.

Expand Down

0 comments on commit 8e4df08

Please sign in to comment.