Skip to content

Use git tag to tag docker image #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions .github/workflows/mainbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
---
name: main build
on:
push:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Starting Report
run: |
echo Git Ref: ${{ github.event.head_commit.id }}
echo GitHub Event: ${{ github.event_name }}
echo Disk usage
df -h
echo Memory
free -m
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: |
${{ github.event.repository.full_name }}:${{ github.event.head_commit.id }}
${{ github.event.repository.full_name }}:latest

name: main build
on:
push:
branches:
- "main"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
steps:
- name: Starting Report
run: |
echo Git Ref: ${{ github.event.head_commit.id }}
echo GitHub Event: ${{ github.event_name }}
echo Disk usage
df -h
echo Memory
free -m
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: |
${{ github.event.repository.full_name }}:${{ github.event.head_commit.id }}
${{ github.event.repository.full_name }}:latest
88 changes: 44 additions & 44 deletions .github/workflows/prbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
---
name: PR build
on:
pull_request_target:
paths-ignore:
- '.github/workflows/**'
branches:
- "main"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Starting Report
run: |
echo Git Ref: ${{ github.event.pull_request.head.ref }}
echo GitHub Event: ${{ github.event_name }}
echo Disk usage
df -h
echo Memory
free -m
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: |
${{ github.event.pull_request.head.repo.full_name }}:latest

name: PR build
on:
pull_request_target:
paths-ignore:
- ".github/workflows/**"
branches:
- "main"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
steps:
- name: Starting Report
run: |
echo Git Ref: ${{ github.event.pull_request.head.ref }}
echo GitHub Event: ${{ github.event_name }}
echo Disk usage
df -h
echo Memory
free -m
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: |
${{ github.event.pull_request.head.repo.full_name }}:latest
82 changes: 42 additions & 40 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,54 @@ on:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-[0-9]+"
paths-ignore:
- '.github/workflows/**'
- ".github/workflows/**"

env:
OCIREPO: lfedge/eve-rust

jobs:
build_and_push:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get rust version
id: rust_version
run: |
RUST_VERSION=$(awk -F= '/ARG RUST_VERSION/ {print $2}' Dockerfile)
# make sure we got a rust version
if [ -z "$RUST_VERSION" ]; then
echo "Failed to get RUST_VERSION"
exit 1
fi
# strip off any potential eve-specific extensions to the tag
TAG="${{ github.ref_name }}"
TAG="${TAG%%-*}"
if [ "$TAG" != "$RUST_VERSION" ]; then
echo "Tag $TAG does not match RUST_VERSION $RUST_VERSION"
exit 1
fi
echo "::set-output name=RUST_VERSION::$RUST_VERSION"
- name: Login to Docker Hub
if: ${{ github.event.repository.full_name }} == 'lf-edge/eve-rust'
uses: docker/login-action@v3
with:
username: ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }}
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.OCIREPO }}:${{ steps.rust_version.outputs.RUST_VERSION }}
${{ env.OCIREPO }}:latest
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get rust version
id: rust_version
run: |
RUST_VERSION=$(awk -F= '/ARG RUST_VERSION/ {print $2}' Dockerfile)
# make sure we got a rust version
if [ -z "$RUST_VERSION" ]; then
echo "Failed to get RUST_VERSION"
exit 1
fi
# strip off any potential eve-specific extensions to the tag
TAG="${{ github.ref_name }}"
TAG="${TAG%%-*}"
if [ "$TAG" != "$RUST_VERSION" ]; then
echo "Tag $TAG does not match RUST_VERSION $RUST_VERSION"
exit 1
fi
echo "::set-output name=IMAGE_TAG::${{ github.ref_name }}"
- name: Login to Docker Hub
if: ${{ github.event.repository.full_name }} == 'lf-edge/eve-rust'
uses: docker/login-action@v3
with:
username: ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }}
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.OCIREPO }}:${{ steps.rust_version.outputs.IMAGE_TAG }}
${{ env.OCIREPO }}:latest