bot-api/.gitea/workflows/build.yaml

79 lines
2.8 KiB
YAML
Raw Normal View History

name: Test and build image
2024-01-07 11:54:46 +00:00
on:
push:
branches:
- main
- develop
jobs:
unit-test:
2024-01-07 11:58:32 +00:00
container:
2024-01-07 12:15:08 +00:00
image: docker:dind
volumes:
- /usr/local/share/.cache/yarn:/usr/local/share/.cache/yarn
- /var/lib/docker/image:/var/lib/docker/image
- /var/lib/docker/overlay2:/var/lib/docker/overlay2
2024-01-07 13:55:41 +00:00
- /var/lib/docker/buildkit:/var/lib/docker/buildkit
2024-01-07 11:54:46 +00:00
steps:
- name: Starting docker daemon
run: docker-init -- dockerd --host=unix:///var/run/docker.sock &
2024-01-07 12:15:08 +00:00
- name: Installing necessary packages
run: apk add yarn git curl bash
- name: Check out repository code
2024-01-07 12:12:19 +00:00
uses: actions/checkout@v3
- name: Install project dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: Run docker-compose
run: docker compose down -v && docker compose run bot-api bun test
2024-01-07 11:54:46 +00:00
build:
container:
2024-01-07 12:15:08 +00:00
image: docker:dind
2024-01-07 13:15:37 +00:00
volumes:
- /data/.cache/act:/data/.cache/act
- /var/lib/docker/image:/var/lib/docker/image
- /var/lib/docker/overlay2:/var/lib/docker/overlay2
2024-01-07 13:55:41 +00:00
- /var/lib/docker/buildkit:/var/lib/docker/buildkit
2024-01-07 11:54:46 +00:00
needs: unit-test
steps:
2024-01-07 12:39:53 +00:00
- name: Starting docker daemon
run: docker-init -- dockerd --host=unix:///var/run/docker.sock &
2024-01-07 12:15:08 +00:00
- name: Installing necessary packages
run: apk add nodejs git curl bash
2024-01-07 11:54:46 +00:00
- name: Checkout
2024-01-07 12:12:19 +00:00
uses: actions/checkout@v3
2024-01-07 11:54:46 +00:00
- name: Docker meta
id: meta
2024-01-07 12:35:30 +00:00
uses: https://github.com/docker/metadata-action@v4
2024-01-07 11:54:46 +00:00
with:
# list of Docker images to use as base name for tags
images: |
fedi-image-bot/bot-api
2024-01-07 12:12:19 +00:00
git.fai.st/fedi-image-bot/bot-api
2024-01-07 11:54:46 +00:00
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
2024-01-07 12:12:19 +00:00
type=sha
2024-01-07 11:54:46 +00:00
- name: Set up QEMU
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
2024-01-07 12:35:30 +00:00
uses: docker/setup-qemu-action@v2
2024-01-07 11:54:46 +00:00
- name: Set up Docker Buildx
2024-01-07 12:35:30 +00:00
uses: docker/setup-buildx-action@v2
2024-01-07 11:54:46 +00:00
- name: Login to fai.st docker registry
uses: docker/login-action@v2
with:
registry: git.fai.st
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
2024-01-07 11:54:46 +00:00
- name: Build and push
2024-01-07 12:35:30 +00:00
uses: docker/build-push-action@v4
2024-01-07 11:54:46 +00:00
with:
platforms: linux/amd64,linux/arm64
2024-01-07 13:14:56 +00:00
context: .
2024-01-07 11:54:46 +00:00
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=fedi-image-bot/bot-api:latest
2024-01-07 12:12:19 +00:00
cache-to: type=inline