Skip to content

Merge pull request #3 from XEPARE/v11 #14

Merge pull request #3 from XEPARE/v11

Merge pull request #3 from XEPARE/v11 #14

Workflow file for this run

name: Build
on:
push:
branches:
- '*'
env:
IMAGE_NAME: laravel-app
jobs:
# auth-test:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v2
#
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
push:
# needs: auth-test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Install composer dependencies
uses: php-actions/composer@v6
with:
php_version: "8.2"
args: --profile --ignore-platform-reqs --optimize-autoloader
dev: no
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install node dependencies
run: |
npm install
npm run build
- name: Build image
run: docker build . --file docker/app/Dockerfile --tag $IMAGE_NAME
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
COMMIT=$(echo "${{ github.sha }}")
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$COMMIT
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$COMMIT
# - name: Send Telegram Message
# run: |
# IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# curl -X POST -H 'Content-Type: application/json' -d '{"chat_id": "${{ secrets.TELEGRAM_CHAT }}", "parse_mode": "markdown", "text": "*[${{ github.repository }}]* finished image-build:
# Branch: *${{ github.ref }}*
# Commit: [${{ github.event.commits[0].message }}](${{ github.event.commits[0].url }})
# Workflow: *${{ github.workflow }}*
# - [Changes](https://github.com/${{ github.repository }}/commit/${{github.sha}})
# - [Workflow](https://github.com/${{ github.repository }}/actions/runs/${{github.run_id}})", "disable_notification": false}' https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage