49 lines
1.9 KiB
YAML
49 lines
1.9 KiB
YAML
name: Build and Publish
|
|
on:
|
|
push:
|
|
branches:
|
|
- "**"
|
|
workflow_dispatch:
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: catthehacker/ubuntu:act-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: https://github.com/actions/checkout@v4
|
|
- name: Login al registry di Gitea
|
|
run: |
|
|
echo "${{ secrets.AUTHTOKEN }}" | docker login ${{ vars.REGISTRY_URL }} -u ${{ github.repository_owner }} --password-stdin
|
|
- name: Extract build artifacts
|
|
run: |
|
|
docker build --target artifacts --output type=local,dest=./out .
|
|
ls -la ./out/
|
|
tar -czf build-artifact.tar.gz -C ./out/dist .
|
|
- name: Build immagine Docker
|
|
run: |
|
|
IMAGE_NAME="${{ vars.REGISTRY_URL }}/${{ github.repository }}"
|
|
docker build \
|
|
--target production \
|
|
-t ${IMAGE_NAME}:${{ github.sha }} \
|
|
-t ${IMAGE_NAME}:${{ github.ref_name}} \
|
|
-t ${IMAGE_NAME}:latest \
|
|
.
|
|
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
|
|
- name: Push immagine Docker
|
|
run: |
|
|
docker push ${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
docker push ${{ env.IMAGE_NAME }}:${{ github.ref_name }}
|
|
docker push ${{ env.IMAGE_NAME }}:latest
|
|
echo "Docker image pushed successfully!"
|
|
- name: Upload to Gitea Package Registry
|
|
run: |
|
|
VERSION="${GITHUB_REF_NAME:-main}"
|
|
REPO_NAME="${{ github.event.repository.name }}"
|
|
curl -X PUT \
|
|
-H "Authorization: token ${{ secrets.AUTHTOKEN }}" \
|
|
-T build-artifact.tar.gz \
|
|
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/packages/generic/${REPO_NAME}/${VERSION}/build-artifact.tar.gz"
|
|
echo "Artifact uploaded to Package Registry!"
|
|
echo "Download at: ${{ github.server_url }}/${{ github.repository }}/-/packages"
|