mobility-accounts/.gitea/workflows/build.yml

83 lines
2.0 KiB
YAML
Raw Permalink Normal View History

name: Build and Push Docker Image
on:
push:
2024-04-03 08:00:47 +00:00
tags:
- '*'
branches:
- main
- dev
jobs:
build_and_push:
2024-03-20 10:46:03 +00:00
runs-on: ubuntu-latest
2024-03-21 09:59:05 +00:00
steps:
- name: Install Docker
run: |
apt-get update
apt-get install -y docker.io
2024-03-21 09:46:21 +00:00
- name: Checkout Repository
2024-03-22 07:46:00 +00:00
uses: actions/checkout@v4
2024-03-22 07:47:28 +00:00
- name: Set Kubernetes Context
uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{secrets.buildx_kubeconfig}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: kubernetes
driver-opts: |
namespace=gitea
2024-03-24 19:04:50 +00:00
- name: Login to Docker Registry
uses: docker/login-action@v3
2024-03-22 14:04:43 +00:00
with:
registry: git.coopgo.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
2024-04-03 09:23:59 +00:00
- name: Extract metadata (tags, labels) for Docker image
id: metadata
uses: docker/metadata-action@v3
with:
images: git.coopgo.io/${{gitea.repository}}
2024-04-03 09:31:27 +00:00
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
2024-04-03 09:23:59 +00:00
flavor: |
latest=auto
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
2024-04-03 09:23:59 +00:00
${{ steps.metadata.outputs.tags }}
build-args: |
2024-03-22 14:04:43 +00:00
ACCESS_TOKEN_USR=${{gitea.actor}}
2024-03-24 19:00:26 +00:00
ACCESS_TOKEN_PWD=${{gitea.token}}
# BUILD WITH KANIKO
# - name: Kaniko build and push
# uses: aevea/action-kaniko@master
# with:
# build_file: Dockerfile
# registry: git.coopgo.io
# username: ${{secrets.registry_user}}
# password: ${{secrets.registry_token}}
# image: ${{gitea.repository}}
# tag: ${{gitea.ref_name}}
# cache: true
# cache_registry: git.coopgo.io/${{gitea.repository}}/cache
# extra-args: |
# ACCESS_TOKEN_USR=${{gitea.actor}}
# ACCESS_TOKEN_PWD=${{gitea.token}}
2024-03-24 19:04:50 +00:00