2024-06-05 10:47:12 +00:00
|
|
|
name: build-image
|
2024-06-05 10:50:12 +00:00
|
|
|
on: [push]
|
2024-06-05 03:19:34 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-06-05 11:33:46 +00:00
|
|
|
semrel_dryrun:
|
|
|
|
name: Semantic Release (Dry-run)
|
|
|
|
runs-on: dind-rootless
|
|
|
|
outputs:
|
|
|
|
version: ${{ steps.sem_rel.outputs.version }}
|
|
|
|
steps:
|
|
|
|
- name: Check out repository code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 20
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
npm install \
|
|
|
|
semantic-release \
|
|
|
|
@semantic-release/commit-analyzer \
|
|
|
|
@semantic-release/exec
|
|
|
|
- name: Semantic Release (dry-run)
|
|
|
|
id: sem_rel
|
|
|
|
run: |
|
|
|
|
npx semantic-release \
|
|
|
|
--package @semantic-release/exec \
|
|
|
|
--package semantic-release \
|
|
|
|
--branches ${{ gitea.refname }} \
|
|
|
|
--tag-format 'v${version}' \
|
|
|
|
--dry-run \
|
|
|
|
--plugins @semantic-release/commit-analyzer,@semantic-release/exec \
|
|
|
|
--analyzeCommits @semantic-release/commit-analyzer \
|
|
|
|
--verifyRelease @semantic-release/exec \
|
|
|
|
--verifyReleaseCmd 'echo "version=${nextRelease.version}" >> $GITHUB_OUTPUT'
|
|
|
|
env:
|
|
|
|
GIT_CREDENTIALS: ${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_APIKEY }}
|
|
|
|
- name: Assert semantic release output
|
|
|
|
run: |
|
|
|
|
[[ -z "${{ steps.sem_rel.outputs.version }}" ]] && {
|
|
|
|
echo 'No release tag - exiting'; exit 1
|
|
|
|
} || {
|
|
|
|
echo 'Release tag set correctly: ${{ steps.sem_rel.outputs.version }}'; exit 0
|
|
|
|
}
|
|
|
|
|
2024-06-05 10:47:12 +00:00
|
|
|
build-image:
|
|
|
|
name: build-image
|
2024-06-05 11:24:36 +00:00
|
|
|
runs-on: dind
|
2024-06-05 11:33:46 +00:00
|
|
|
needs: semrel_dryrun
|
|
|
|
container: ghcr.io/catthehacker/ubuntu:act-latest
|
2024-06-05 03:19:34 +00:00
|
|
|
steps:
|
2024-06-05 11:33:46 +00:00
|
|
|
- name: Check out repository code
|
|
|
|
uses: actions/checkout@v4
|
2024-06-05 10:47:12 +00:00
|
|
|
- name: Install QEMU
|
2024-06-05 03:19:34 +00:00
|
|
|
run: |
|
2024-06-05 10:47:12 +00:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y qemu-user-static
|
|
|
|
- name: Set up Docker Context for Buildx
|
|
|
|
id: buildx-context
|
2024-06-05 03:19:34 +00:00
|
|
|
run: |
|
2024-06-05 10:47:12 +00:00
|
|
|
docker context create builders
|
2024-06-05 11:33:46 +00:00
|
|
|
env:
|
|
|
|
DOCKER_HOST: tcp://docker:2376/
|
|
|
|
DOCKER_TLS_CERTDIR: /certs
|
|
|
|
DOCKER_TLS_VERIFY: 1
|
|
|
|
DOCKER_CERT_PATH: "/certs/client"
|
2024-06-05 10:47:12 +00:00
|
|
|
- name: Setup Docker Buildx
|
|
|
|
id: buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
with:
|
|
|
|
# buildkitd-flags: --debug
|
|
|
|
endpoint: builders
|
2024-06-05 03:19:34 +00:00
|
|
|
env:
|
2024-06-05 10:47:12 +00:00
|
|
|
DOCKER_HOST: "tcp://docker:2376/"
|
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
|
|
|
DOCKER_TLS_VERIFY: 1
|
|
|
|
DOCKER_CERT_PATH: "/certs/client"
|
|
|
|
- name: Login to Gitea
|
|
|
|
uses: docker/login-action@v3
|
2024-06-05 03:19:34 +00:00
|
|
|
with:
|
|
|
|
registry: code.spamasaurus.com
|
2024-06-05 10:47:12 +00:00
|
|
|
username: ${{ gitea.actor }}
|
2024-06-05 03:19:34 +00:00
|
|
|
password: ${{ secrets.GIT_APIKEY }}
|
2024-06-05 10:47:12 +00:00
|
|
|
- name: Build and push the image
|
|
|
|
uses: docker/build-push-action@v5
|
2024-06-05 03:19:34 +00:00
|
|
|
with:
|
2024-06-05 11:33:46 +00:00
|
|
|
# push: ${{ gitea.event_name != 'pull_request' }}
|
2024-06-05 10:47:12 +00:00
|
|
|
platforms: linux/amd64
|
2024-06-05 11:33:46 +00:00
|
|
|
context: djpbessems/packer-extended
|
|
|
|
tags: ${{ needs.semrel_dryrun.outputs.version }}
|
2024-06-05 03:19:34 +00:00
|
|
|
env:
|
2024-06-05 10:47:12 +00:00
|
|
|
DOCKER_HOST: "tcp://docker:2376/"
|
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
|
|
|
DOCKER_TLS_VERIFY: 1
|
|
|
|
DOCKER_CERT_PATH: "/certs/client"
|