rename file
All checks were successful
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
Full Build and Docker Push Workflow / Builder (pull_request) Successful in 1m47s
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
All checks were successful
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
Full Build and Docker Push Workflow / Builder (pull_request) Successful in 1m47s
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
This commit is contained in:
88
.gitea/workflows/be-img-build-and-push.yaml
Normal file
88
.gitea/workflows/be-img-build-and-push.yaml
Normal file
@ -0,0 +1,88 @@
|
||||
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
|
||||
echo "Cleanup done."
|
||||
|
||||
Reference in New Issue
Block a user