michals-silly-game-frontend/.forgejo/workflows/deploy.yaml

76 lines
2.7 KiB
YAML
Raw Normal View History

2025-04-08 10:23:02 +02:00
name: ci
2025-04-08 10:10:23 +02:00
on: push
2025-04-07 12:58:47 +02:00
jobs:
2025-04-08 10:23:02 +02:00
build:
runs-on: ubuntu-22.04
2025-04-07 12:58:47 +02:00
steps:
2025-04-08 11:13:12 +02:00
- name: Repository meta
2025-04-08 10:16:17 +02:00
id: repository
run: |
registry=${{ github.server_url }}
registry=${registry##http*://}
echo "registry=${registry}" >> "$GITHUB_OUTPUT"
echo "registry=${registry}"
repository="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
echo "repository=${repository}" >> "$GITHUB_OUTPUT"
2025-04-10 11:13:35 +02:00
echo "repository=${repository}"
2025-04-08 11:13:12 +02:00
- name: Docker meta
2025-04-08 10:16:17 +02:00
uses: docker/metadata-action@v5
id: docker
with:
images: ${{ steps.repository.outputs.registry }}/${{ steps.repository.outputs.repository }}
2025-04-08 11:13:12 +02:00
- name: Login to registry
2025-04-07 12:58:47 +02:00
uses: docker/login-action@v3
with:
2025-04-08 10:16:17 +02:00
registry: ${{ steps.repository.outputs.registry }}
username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_TOKEN }}
2025-04-08 11:13:12 +02:00
- name: Set up QEMU
2025-04-08 10:23:02 +02:00
uses: docker/setup-qemu-action@v3
2025-04-08 11:13:12 +02:00
- name: Set up Docker Buildx
2025-04-08 10:23:02 +02:00
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: '--allow-insecure-entitlement network.host'
driver-opts: network=host
2025-04-08 13:36:34 +02:00
- name: Checkout code
uses: actions/checkout@v4
2025-04-08 12:32:51 +02:00
- name: Lint test
2025-04-08 11:13:12 +02:00
run: |
2025-04-08 11:36:52 +02:00
registry=${{ github.server_url }}
registry=${registry##http*://}
2025-04-08 11:40:02 +02:00
repository="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
2025-04-08 11:51:43 +02:00
fullrepo=https://${registry}/${repository}.git
git init
2025-04-10 11:15:02 +02:00
# git pull ${fullrepo}
2025-04-08 12:25:07 +02:00
npm install @angular/cli
2025-04-08 12:37:29 +02:00
npm run lint
2025-04-08 13:36:34 +02:00
- name: Update version
2025-04-08 13:34:01 +02:00
run: |
2025-04-08 13:40:18 +02:00
set -e
current_version=$(jq -r '.version' package.json)
echo "Current version: $current_version"
IFS='.' read -r major minor patch <<< "$current_version"
new_patch=$((patch + 1))
new_version="$major.$minor.$new_patch"
echo "New version: $new_version"
2025-04-08 13:34:01 +02:00
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "GitHub Actions Bot"
2025-04-09 15:09:00 +02:00
# git checkout -- package-lock.json package.json
2025-04-10 11:15:02 +02:00
git stash
2025-04-08 13:45:17 +02:00
git pull
2025-04-10 11:15:02 +02:00
git stash pop
2025-04-09 15:09:00 +02:00
jq ".version = \"$new_version\"" package.json > temp.json && mv temp.json package.json
2025-04-08 13:34:01 +02:00
git add .
2025-04-14 11:41:41 +02:00
git commit -m "Automated update by Forgejo Actions"
2025-04-10 11:13:35 +02:00
git push origin HEAD:${{ github.ref_name }}
2025-04-08 11:05:09 +02:00
- name: Build and push
2025-04-08 10:23:02 +02:00
uses: docker/build-push-action@v6
2025-04-07 12:58:47 +02:00
with:
push: true
2025-04-08 10:23:02 +02:00
allow: network.host
network: host
2025-04-15 13:35:40 +02:00
platforms: linux/amd64
2025-04-24 11:25:10 +02:00
tags: $(jq -r '.version' package.json)