2023-12-20 07:30:15 +00:00
|
|
|
name: 'Build and Release Docker Image'
|
|
|
|
author: 'Neshura'
|
|
|
|
|
2024-01-01 04:51:51 +00:00
|
|
|
on:
|
2023-12-20 07:30:15 +00:00
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- '[0-9]+.[0-9]+.[0-9]+'
|
2024-01-01 04:51:51 +00:00
|
|
|
- '[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
|
2023-12-20 07:30:15 +00:00
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
runs-on: docker
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checking Out Repository Code
|
|
|
|
uses: https://code.forgejo.org/actions/checkout@v3
|
|
|
|
-
|
|
|
|
name: Get Yarn Cache Directory
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
|
|
|
-
|
|
|
|
name: Set Up Yarn Cache
|
|
|
|
uses: actions/cache@v3
|
|
|
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
|
|
|
-
|
|
|
|
name: Install Dependencies
|
|
|
|
run: yarn install
|
|
|
|
-
|
|
|
|
name: Run Linter
|
|
|
|
run: yarn lint
|
|
|
|
-
|
|
|
|
name: Check if Version in package.json matches Tag
|
|
|
|
run: |
|
2024-01-01 19:47:58 +00:00
|
|
|
VERSION=$(cat package.json | grep "version" | sed 's/.*://' | tr -d , | tr -d \" | tr -d " " )
|
|
|
|
if test $VERSION != "${{ github.ref_name }}"; then
|
2023-12-20 07:30:15 +00:00
|
|
|
echo "Expected Version is: '${{ github.ref_name }}' actual Version is: '$VERSION'";
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Version is: '$VERSION'";
|
|
|
|
fi
|
|
|
|
|
|
|
|
build:
|
|
|
|
needs: test
|
|
|
|
if: success()
|
|
|
|
runs-on: dind
|
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
-
|
|
|
|
name: Login to Docker Hub
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: forgejo.neshweb.net
|
|
|
|
username: ${{ secrets.FORGEJO_USERNAME }}
|
|
|
|
password: ${{ secrets.FORGEJO_TOKEN }}
|
2024-01-01 18:44:39 +00:00
|
|
|
-
|
|
|
|
name: Determine Docker tags
|
2024-01-01 19:33:29 +00:00
|
|
|
id: tags
|
2024-01-01 18:44:39 +00:00
|
|
|
run: |
|
2024-01-01 20:04:32 +00:00
|
|
|
if ${{ github.ref_name }} | grep -qi '\-rc' ; then
|
2024-01-01 19:51:36 +00:00
|
|
|
echo latest=forgejo.neshweb.net/neshweb-sites/${{ github.event.repository.name }}:preview >> $GITHUB_OUTPUT;
|
2024-01-01 18:44:39 +00:00
|
|
|
else
|
2024-01-01 19:51:36 +00:00
|
|
|
echo latest=forgejo.neshweb.net/neshweb-sites/${{ github.event.repository.name }}:latest >> $GITHUB_OUTPUT;
|
2024-01-01 18:44:39 +00:00
|
|
|
fi
|
2024-01-01 19:51:36 +00:00
|
|
|
echo version=forgejo.neshweb.net/neshweb-sites/${{ github.event.repository.name }}:${{ github.ref_name }} >> $GITHUB_OUTPUT;
|
2023-12-20 07:30:15 +00:00
|
|
|
-
|
|
|
|
name: Push to Package Registry
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
push: true
|
2024-01-01 19:33:29 +00:00
|
|
|
tags: ${{ steps.tags.outputs.version }}, ${{ steps.tags.outputs.latest }}
|
2023-12-20 09:46:55 +00:00
|
|
|
|
2023-12-20 09:46:41 +00:00
|
|
|
release:
|
|
|
|
needs: build
|
|
|
|
if: success()
|
|
|
|
runs-on: docker
|
2023-12-20 09:47:09 +00:00
|
|
|
steps:
|
2023-12-20 07:30:15 +00:00
|
|
|
-
|
|
|
|
name: Release New Version
|
|
|
|
uses: actions/forgejo-release@v1
|
|
|
|
with:
|
|
|
|
direction: upload
|
|
|
|
url: https://forgejo.neshweb.net
|
|
|
|
release-dir: release
|
|
|
|
token: ${{ secrets.FORGEJO_TOKEN }}
|
|
|
|
tag: ${{ github.ref_name }}
|