Skip to content

Commit

Permalink
ariang: add GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
leonismoe committed Oct 25, 2021
1 parent d050f4a commit ebe7ebc
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 5 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build-ariang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build AriaNg

on:
workflow_dispatch:
inputs:
version:
description: 'target AriaNg version'
required: false
default: ''

env:
VERSION: ${{ github.event.inputs.version }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}


jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log into DockerHub
if: ${{ github.event_name != 'pull_request' && github.actor == env.DOCKERHUB_USERNAME }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log into GitHub Packages
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build ariang
env:
DOCKER_REPO: "${{ github.actor }}/ariang"
working-directory: ariang
run: |
./hooks/build
export DOCKER_REPO="ghcr.io/$DOCKER_REPO"
./hooks/build
- name: Extract version
working-directory: ariang
run: |
. .env.local
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
- name: Push to DockerHub
if: ${{ github.event_name != 'pull_request' && github.actor == env.DOCKERHUB_USERNAME }}
working-directory: ariang
run: |
export DOCKER_REPO="${{ github.actor }}/ariang"
./hooks/push
- name: Push to GitHub Packages
if: ${{ github.event_name != 'pull_request' }}
working-directory: ariang
run: |
export DOCKER_REPO="ghcr.io/${{ github.actor }}/ariang"
./hooks/push
- name: Cleanup
run: |
if [ ! -z "$(docker images -q -f 'reference=${{ github.actor }}/ariang*')" ]; then
docker rmi $(docker images -q -f 'reference=${{ github.actor }}/ariang*')
fi
docker image prune -f
11 changes: 6 additions & 5 deletions ariang/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ RUN set -xe \

WORKDIR /build
ARG CHECKOUT_VERSION
ARG NODE_VERSION=10.24.1

RUN set -xe \
&& apk add --no-cache curl xxd qpdf \
&& curl -sSO https://unofficial-builds.nodejs.org/download/release/v10.24.0/node-v10.24.0-linux-x64-musl.tar.xz \
&& tar -Jxf node-v10.24.0-linux-x64-musl.tar.xz \
&& rm -f node-v10.24.0-linux-x64-musl.tar.xz \
&& export PATH=/build/node-v10.24.0-linux-x64-musl/bin:$PATH \
&& curl -sSO https://unofficial-builds.nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64-musl.tar.xz \
&& tar -Jxf node-v${NODE_VERSION}-linux-x64-musl.tar.xz \
&& rm -f node-v${NODE_VERSION}-linux-x64-musl.tar.xz \
&& export PATH=/build/node-v${NODE_VERSION}-linux-x64-musl/bin:$PATH \
&& git clone https://github.com/mayswind/AriaNg.git \
&& cd AriaNg \
&& export LATEST_VERSION=`git tag --sort=v:refname | grep '^\d' | tail -n1` \
Expand All @@ -32,7 +33,7 @@ RUN set -xe \
&& npx gulp build-bundle \
&& cp dist/index.html /build/ \
&& cd /build \
&& rm -rf AriaNg node-v10.24.0-linux-x64-musl \
&& rm -rf AriaNg node-v${NODE_VERSION}-linux-x64-musl \
&& zlib-flate -compress=9 < index.html > index.html.deflate \
&& xxd -i index.html.deflate > index_html_deflate.c \
&& apk del curl xxd qpdf
Expand Down

0 comments on commit ebe7ebc

Please sign in to comment.