feat: update Docker image build workflow to use dynamic registry URL and improve tag handling
Some checks failed
Build Docker Image / build (push) Failing after 13s
Some checks failed
Build Docker Image / build (push) Failing after 13s
This commit is contained in:
59
.gitea/workflows/build-image.yaml
Normal file
59
.gitea/workflows/build-image.yaml
Normal file
@@ -0,0 +1,59 @@
|
||||
name: Build Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
GITEA_REGISTRY: ${{ gitea.server_url }}
|
||||
GITEA_USERNAME: ${{ gitea.actor }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Determine image tag
|
||||
id: tag
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
|
||||
TAG=${GITHUB_REF#refs/tags/}
|
||||
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
|
||||
TAG=main
|
||||
else
|
||||
echo "Not on main branch or a tag, skipping build"
|
||||
exit 1
|
||||
fi
|
||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
# Remove protocol from registry URL
|
||||
REGISTRY="${{ env.GITEA_REGISTRY }}"
|
||||
REGISTRY="${REGISTRY#https://}"
|
||||
REGISTRY="${REGISTRY#http://}"
|
||||
echo "registry=$REGISTRY" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ steps.tag.outputs.registry }}
|
||||
username: ${{ vars.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ steps.tag.outputs.registry }}/${{ gitea.repository }}:${{ steps.tag.outputs.tag }}
|
||||
${{ steps.tag.outputs.registry }}/${{ gitea.repository }}:latest
|
||||
1
package-lock.json
generated
1
package-lock.json
generated
@@ -6,7 +6,6 @@
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "onepiecedle",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@libsql/client": "^0.17.0",
|
||||
"@sveltejs/adapter-node": "^5.5.4",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "onepiecedle",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
||||
Reference in New Issue
Block a user