Files
stock-exporter/.github/workflows/build.yml
ztimson 7d714cb406
All checks were successful
Build Container / Build Container (push) Successful in 2s
Build Container / Git Tag (push) Successful in 2s
Actions: Fixing git url
2025-04-17 11:10:49 -04:00

44 lines
1.7 KiB
YAML

name: Build Container
run-name: Build Container
on:
push:
jobs:
container:
name: Build Container
runs-on: ubuntu-latest
container: docker
steps:
- name: Build Container
run: |
git clone -b "${{github.ref_name}}" "${{github.server_url%%://*}}://${{github.token}}@${{github.server_url#*://}}/${{github.repository}}.git" .
REGISTRY="$(echo ${{github.server_url}} | sed s%http://%% | sed s%https://%% )"
VERSION="$(cat package.json | grep 'version' | grep -Eo '([0-9]+\.?)+(-[0-9a-zA-Z\-\.]+)?')"
docker login -u ${{github.repository_owner}} -p ${{secrets.DEPLOY_TOKEN}} $REGISTRY
docker build -t $REGISTRY/${{github.repository}}:${{github.ref_name}} .
docker push $REGISTRY/${{github.repository}}:${{github.ref_name}}
if [ '${{github.ref_name}}' == 'master' ]; then
docker tag $REGISTRY/${{github.repository}}:${{github.ref_name}} $REGISTRY/${{github.repository}}:$VERSION
docker push $REGISTRY/${{github.repository}}:$VERSION
docker tag $REGISTRY/${{github.repository}}:${{github.ref_name}} $REGISTRY/${{github.repository}}:latest
docker push $REGISTRY/${{github.repository}}:latest
fi
tag:
name: Git Tag
runs-on: ubuntu-latest
container: alpine/git
steps:
- name: Git Tag
run: |
git clone -b "${{github.ref_name}}" "${{github.server_url%%://*}}://${{github.token}}@${{github.server_url#*://}}/${{github.repository}}.git" .
VERSION="$(cat package.json | grep 'version' | grep -Eo '([0-9]+\.?)+(-[0-9a-zA-Z\-\.]+)?')"
git tag -f $VERSION ${{github.sha}}
git push -f origin $VERSION