148 lines
4.7 KiB
YAML
148 lines
4.7 KiB
YAML
on: [push]
|
|
name: Deploy workflow
|
|
jobs:
|
|
install:
|
|
runs-on: ubuntu-20.04
|
|
strategy:
|
|
matrix:
|
|
node-version: [14.x]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2.4.0
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v2.4.1
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
- name: Get yarn cache directory path
|
|
id: yarn-cache-dir-path
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
- uses: actions/cache@v2.1.6
|
|
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
|
|
run: yarn
|
|
- name: Lint
|
|
run: yarn lint
|
|
- name: Build
|
|
run: yarn build
|
|
|
|
- name: Create Release
|
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
release_name: ${{ github.ref }}
|
|
draft: true
|
|
prerelease: false
|
|
- name: Create Tar Ball
|
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
|
run: tar cJf yacd.tar.xz public
|
|
- name: Upload Release Asset
|
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
|
id: upload-release-asset
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ./yacd.tar.xz
|
|
asset_name: yacd.tar.xz
|
|
asset_content_type: application/x-gzip
|
|
|
|
- name: Push to gh-pages
|
|
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || github.event.ref == 'refs/heads/publish')
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
|
PUBLISH_DIR: public
|
|
BRANCH: gh-pages
|
|
run: |
|
|
cd $PUBLISH_DIR
|
|
ls -l
|
|
git init
|
|
git config user.name "${GITHUB_ACTOR}"
|
|
git config user.email "${GITHUB_ACTOR}@noreply.github.com"
|
|
git add .
|
|
git status
|
|
git commit -m "Push to gh-pages"
|
|
git push -f https://$GITHUB_ACTOR:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:$BRANCH
|
|
|
|
- name: Send Notification
|
|
uses: haishanh/actions-telegram-notification@v1
|
|
if: ${{ always() }}
|
|
with:
|
|
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
|
|
job-status: ${{ job.status }}
|
|
|
|
docker:
|
|
needs: install
|
|
runs-on: ubuntu-20.04
|
|
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || startsWith(github.event.ref, 'refs/heads/v0.'))
|
|
steps:
|
|
- uses: actions/checkout@v2.4.0
|
|
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Docker meta
|
|
id: docker_meta
|
|
uses: docker/metadata-action@v3.6.0
|
|
with:
|
|
images: haishanh/yacd
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1.2.0
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
with:
|
|
version: latest
|
|
|
|
- name: Builder instance name
|
|
run: echo ${{ steps.buildx.outputs.name }}
|
|
- name: Available platforms
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v1.10.0
|
|
with:
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
|
|
- name: Build and push
|
|
id: docker_build
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
- name: Image digest
|
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
|
|
- name: Send Notification
|
|
uses: haishanh/actions-telegram-notification@v1
|
|
if: ${{ always() }}
|
|
with:
|
|
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
|
|
job-status: ${{ job.status }}
|