Skip to content

Commit

Permalink
! docker image build github action
Browse files Browse the repository at this point in the history
  • Loading branch information
ALERTua committed Jan 8, 2024
1 parent 3e066f2 commit 36d457e
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker Image Latest

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

env:
REGISTRY: ghcr.io


jobs:

build-and-publish-latest:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' # Running this job only for main branch

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: downcase github.repository
run: |
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image Latest
uses: docker/build-push-action@v5
with:
context: .
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
26 changes: 26 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Manual

on:
workflow_dispatch:

jobs:
print-name:
runs-on: ubuntu-latest
steps:
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
shell: bash
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: get-name
run: |
echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV
- name: print-REPO_NAME
run: |
echo "${{ env.REPO_NAME }}"
- name: downcase github.repository
run: |
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
- name: print-IMAGE_NAME
run: |
echo "${{ env.IMAGE_NAME }}"

0 comments on commit 36d457e

Please sign in to comment.