CI/CD - build docker container
This commit is contained in:
46
.github/workflows/docker.yaml
vendored
Normal file
46
.github/workflows/docker.yaml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container:
|
||||
image: quay.io/buildah/stable
|
||||
options: --security-opt seccomp=unconfined --security-opt apparmor=unconfined --device /dev/fuse:rw --privileged
|
||||
|
||||
env:
|
||||
BUILDAH_ISOLATION: chroot
|
||||
STORAGE_DRIVER: vfs
|
||||
|
||||
steps:
|
||||
- name: Install Node.js
|
||||
run: dnf install -y nodejs git
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ssh-user: ${{ secrets.REGISTRY_USER }}
|
||||
token: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
submodules: true
|
||||
|
||||
- name: Login to Registry
|
||||
run: buildah login -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_PASSWORD }} git.kocoder.xyz
|
||||
|
||||
- name: Generate Tag
|
||||
id: tag
|
||||
run: |
|
||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||
echo "value=${{ github.ref_name }}-$(date +%s)-${SHORT_SHA}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Buildah Build
|
||||
run: |
|
||||
buildah build -t ${{ steps.tag.outputs.value }} .
|
||||
buildah tag ${{ steps.tag.outputs.value }} latest
|
||||
|
||||
- name: Push Docker Images
|
||||
run: |
|
||||
buildah push ${{ steps.tag.outputs.value }} docker://git.kocoder.xyz/vt/link-shortening-service:${{ steps.tag.outputs.value }}
|
||||
buildah push latest docker://git.kocoder.xyz/vt/link-shortening-service:latest
|
||||
Reference in New Issue
Block a user