2024-01-07 12:32:01 +00:00
|
|
|
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
|
2024-01-07 12:24:53 +00:00
|
|
|
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 11:54:46 +00:00
|
|
|
steps:
|
2024-01-07 12:24: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
|
2024-01-07 12:24:53 +00:00
|
|
|
run: apk add yarn git curl bash
|
|
|
|
- name: Check out repository code
|
2024-01-07 12:12:19 +00:00
|
|
|
uses: actions/checkout@v3
|
2024-01-07 12:24:53 +00:00
|
|
|
- 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 11:54:46 +00:00
|
|
|
needs: unit-test
|
|
|
|
steps:
|
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:32:01 +00:00
|
|
|
uses: https://github.com/docker/metadata-action@v5
|
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
|
|
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to fai.st docker registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: git.fai.st
|
|
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_PASS }}
|
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
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
|