feat: update CI workflow for Docker image build and push; streamline steps and enhance registry login process
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 33s

This commit is contained in:
2025-08-13 14:25:41 +00:00
parent 9786977b5c
commit 602fe3de60

View File

@@ -1,59 +1,48 @@
name: Build and Push Docker Image
name: CI
on: on:
push: push:
branches: [ main ] branches: [ main, master ]
pull_request: pull_request:
branches: [ main ] branches: [ main, master ]
jobs: jobs:
build: build-and-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install system Dependencies - name: Install system Dependencies
run: | run: |
apt-get update && apt-get install -y curl jq docker.io apt-get update && apt-get install -y curl jq docker.io
- name: Set up Docker - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Node.js - name: Log in to Gitea Container Registry
uses: actions/setup-node@v4 uses: docker/login-action@v3
with: with:
node-version: 18 registry: gitea.portal.tulsacounty.org
username: ${{ gitea.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Install NPM dependencies - name: Extract metadata
run: npm install id: meta
uses: docker/metadata-action@v5
with:
images: gitea.portal.tulsacounty.org/${{ gitea.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix={{branch}}-
- name: Lint (if ESLint is configured) - name: Build and push Docker image
run: | uses: docker/build-push-action@v5
if [ -f .eslintrc.js ] || [ -f .eslintrc.json ] || [ -f .eslintrc ]; then with:
npx eslint . context: .
else file: ./Dockerfile
echo "No ESLint config found, skipping lint." push: true
fi tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# - name: Run tests (uncomment if you add tests)
# run: npm test
- name: Set Docker image tag
id: vars
run: |
TAG=$(git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD)
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Build Docker image
run: |
docker build -t pictshare-browse:${{ steps.vars.outputs.tag }} -t pictshare-browse:latest .
- name: Push Docker image
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker tag pictshare-browse:${{ steps.vars.outputs.tag }} ryanehamil/pictshare-browse:${{ steps.vars.outputs.tag }}
docker tag pictshare-browse:latest ryanehamil/pictshare-browse:latest
docker push ryanehamil/pictshare-browse:${{ steps.vars.outputs.tag }}
docker push ryanehamil/pictshare-browse:latest