Update .gitea/workflows/be-img-build-and-push.yaml
Some checks failed
checks / Set up Node and other necessary dependencies for Frontend Tests and Build (push) Has been skipped
checks / Set up Java for Backend Tests and Build (push) Has been skipped
Gitea Actions Demo / Explore Gitea Actions - 2 (pull_request) Has been skipped
checks / Set up Node and other necessary dependencies for Frontend Tests and Build (pull_request) Has been skipped
checks / Set up Java for Backend Tests and Build (pull_request) Has been skipped
Full Build and Docker Push Workflow / Builder (pull_request) Failing after 2m12s
Some checks failed
checks / Set up Node and other necessary dependencies for Frontend Tests and Build (push) Has been skipped
checks / Set up Java for Backend Tests and Build (push) Has been skipped
Gitea Actions Demo / Explore Gitea Actions - 2 (pull_request) Has been skipped
checks / Set up Node and other necessary dependencies for Frontend Tests and Build (pull_request) Has been skipped
checks / Set up Java for Backend Tests and Build (pull_request) Has been skipped
Full Build and Docker Push Workflow / Builder (pull_request) Failing after 2m12s
This commit is contained in:
@ -1,118 +1,89 @@
|
||||
name: Full Build and Docker Push Workflow
|
||||
run-name: ${{ gitea.actor }} is running a full build and Docker push workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
Builder:
|
||||
runs-on: catthacker-ubuntu-latest
|
||||
steps:
|
||||
- name: Info
|
||||
run: |
|
||||
echo "Triggered by ${{ gitea.event_name }} event"
|
||||
echo "Branch: ${{ gitea.ref }}"
|
||||
echo "Repository: ${{ gitea.repository }}"
|
||||
|
||||
- name: Update apt-get and install Maven
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y maven
|
||||
|
||||
- name: Clone the repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'maven'
|
||||
|
||||
- name: Build with Maven
|
||||
run: |
|
||||
java -version
|
||||
mvn -version
|
||||
mvn -B clean test -Dspring.profiles.active=test
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
#Build Docker image - Images must follow this naming convention: - {registry}/{owner}/{image}
|
||||
- name: Build Docker image
|
||||
env:
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
OWNER: ${{ gitea.actor }}
|
||||
IMAGE_NAME: my-app
|
||||
run: |
|
||||
#docker build -t $GITEA_REGISTRY_URL/$OWNER/my-app:latest .
|
||||
# registry.domain.com/<username>/my-app:latest e.g. git.bepastem.com/eberen/my-app:latest
|
||||
docker build -t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:latest .
|
||||
|
||||
- name: Build and push Docker image using Buildx
|
||||
env:
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
IMAGE_NAME: my-app-backend
|
||||
APP_VERSION: v1.0.0
|
||||
OWNER: ${{ gitea.actor }}
|
||||
LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
|
||||
run: |
|
||||
docker buildx build --platform linux/amd64 -t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:$APP_VERSION .
|
||||
#docker buildx build \
|
||||
# --platform linux/amd64 \
|
||||
# #-t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:latest \
|
||||
# #--push \
|
||||
# .
|
||||
|
||||
- name: Push Docker image to Gitea Registry
|
||||
env:
|
||||
GITEA_USERNAME: ${{ gitea.actor }}
|
||||
LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
run: |
|
||||
# Login securely
|
||||
echo "$LOGIN_TOKEN" | docker login $GITEA_REGISTRY_URL --username $GITEA_USERNAME --password-stdin
|
||||
docker push $GITEA_REGISTRY_URL/$GITEA_USERNAME/my-app:latest
|
||||
docker logout $GITEA_REGISTRY_URL
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
docker images -a
|
||||
docker system prune -f
|
||||
docker images
|
||||
echo "Cleanup done."
|
||||
|
||||
- name: Prepare deploy script
|
||||
run: |
|
||||
echo "Preparing deploy artifacts..."
|
||||
mkdir -p docker/
|
||||
cp docker-compose-dev.yml docker/
|
||||
|
||||
mkdir -p .gitea/scripts
|
||||
cat << 'EOF' > .gitea/scripts/deploy-backend.sh
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
echo "Starting deployment..."
|
||||
# Example: docker-compose -f docker/docker-compose-dev.yml up -d --build
|
||||
echo "Deploying backend..."
|
||||
echo "Deployment completed successfully."
|
||||
EOF
|
||||
|
||||
chmod +x .gitea/scripts/deploy-backend.sh
|
||||
|
||||
- name: Deploy to server via deploy script
|
||||
run: |
|
||||
echo "Listing files..."
|
||||
ls -a
|
||||
ls .gitea/scripts/
|
||||
|
||||
echo "Executing deploy script..."
|
||||
cd .gitea/scripts
|
||||
chmod +x deploy-backend.sh
|
||||
./deploy-backend.sh
|
||||
echo "Deployment done."
|
||||
name: Full Build and Docker Push Workflow
|
||||
run-name: ${{ gitea.actor }} is running a full build and Docker push workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
Builder:
|
||||
runs-on: catthacker-ubuntu-latest
|
||||
steps:
|
||||
- name: Info
|
||||
run: |
|
||||
echo "Triggered by ${{ gitea.event_name }} event"
|
||||
echo "Branch: ${{ gitea.ref }}"
|
||||
echo "Repository: ${{ gitea.repository }}"
|
||||
|
||||
- name: Update apt-get and install Maven
|
||||
run: |
|
||||
apt-get update -y
|
||||
apt-get install -y maven
|
||||
|
||||
- name: Clone the repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'maven'
|
||||
|
||||
- name: Build with Maven
|
||||
run: |
|
||||
java -version
|
||||
mvn -version
|
||||
mvn -B clean test -Dspring.profiles.active=test
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
#Build Docker image - Images must follow this naming convention: - {registry}/{owner}/{image}
|
||||
- name: Build Docker image
|
||||
env:
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
OWNER: ${{ gitea.actor }}
|
||||
IMAGE_NAME: my-app
|
||||
run: |
|
||||
#docker build -t $GITEA_REGISTRY_URL/$OWNER/my-app:latest .
|
||||
# registry.domain.com/<username>/my-app:latest e.g. git.bepastem.com/eberen/my-app:latest
|
||||
docker build -t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:latest .
|
||||
|
||||
- name: Build and push Docker image using Buildx
|
||||
env:
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
IMAGE_NAME: my-app-backend
|
||||
APP_VERSION: v1.0.0
|
||||
OWNER: ${{ gitea.actor }}
|
||||
LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
|
||||
run: |
|
||||
docker buildx build --platform linux/amd64 -t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:$APP_VERSION .
|
||||
#docker buildx build \
|
||||
# --platform linux/amd64 \
|
||||
# #-t $GITEA_REGISTRY_URL/$OWNER/$IMAGE_NAME:latest \
|
||||
# #--push \
|
||||
# .
|
||||
|
||||
- name: Push Docker image to Gitea Registry
|
||||
env:
|
||||
GITEA_USERNAME: ${{ gitea.actor }}
|
||||
LOGIN_TOKEN: ${{ secrets.LOGIN_TOKEN }}
|
||||
GITEA_REGISTRY_URL: ${{ vars.REGISTRY_URL }}
|
||||
run: |
|
||||
# Login securely
|
||||
echo "$LOGIN_TOKEN" | docker login $GITEA_REGISTRY_URL --username $GITEA_USERNAME --password-stdin
|
||||
docker push $GITEA_REGISTRY_URL/$GITEA_USERNAME/my-app:latest
|
||||
docker logout $GITEA_REGISTRY_URL
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
docker images -a
|
||||
docker system prune -f
|
||||
docker images
|
||||
echo "Cleanup done."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user