Skip to content

Commit dc105f6

Browse files
committed
feat: 添加 github action 部署
1 parent 9276621 commit dc105f6

4 files changed

Lines changed: 113 additions & 0 deletions

File tree

.dockerignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# project
2+
config/*.local.yml
3+
config/*.p8
4+
main.rb
5+
Makefile
6+
stores
7+
8+
# docker
9+
Dockerfile*
10+
11+
# common
12+
README.*
13+
.git*
14+
.gitignore
15+
.editorconfig
16+
.rubocop.yml
17+
.ruby-gemset
18+
.ruby-version
19+
.rvmrc
20+
.byebug_history
21+
.history
22+
.bundle
23+
.vscode
24+
.DS_Store
25+
.ruby-gemset
26+
.ruby-version
27+
.codeclimate.yml
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish Nightly Docker Image
2+
on:
3+
push:
4+
paths-ignore:
5+
- '.github/*.yml'
6+
- '*.md'
7+
- '*.yml'
8+
- '.rubocop.yml'
9+
- 'Rakefile'
10+
- 'LICENSE'
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@master
16+
- uses: ruby/setup-ruby@v1
17+
with:
18+
ruby-version: 2.7
19+
bundler-cache: true
20+
- name: build gem
21+
run: |
22+
bundle install
23+
bundle exec rake build
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v1
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v1
28+
- name: Login to GitHub Container Registry
29+
uses: docker/login-action@v1
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.repository_owner }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Publish to Github Registry
35+
uses: docker/build-push-action@v2
36+
with:
37+
context: .
38+
push: true
39+
build-args: |
40+
REPLACE_CHINA_MIRROR=false
41+
tags: icyleaf/app_status_notification:nightly

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM ruby:2.7-alpine
2+
3+
ARG REPLACE_CHINA_MIRROR="true"
4+
ARG ORIGINAL_REPO_URL="http://dl-cdn.alpinelinux.org"
5+
ARG MIRROR_REPO_URL="https://mirrors.tuna.tsinghua.edu.cn"
6+
ARG RUBYGEMS_SOURCE="https://gems.ruby-china.com/"
7+
ARG TZ="Asia/Shanghai"
8+
ARG APP_STATUS_NOTIFICATION_VERSION="0.9.0.beta5"
9+
10+
# System dependencies
11+
RUN set -ex && \
12+
if [[ "$REPLACE_CHINA_MIRROR" == "true" ]]; then \
13+
REPLACE_STRING=$(echo $MIRROR_REPO_URL | sed 's/\//\\\//g') && \
14+
SEARCH_STRING=$(echo $ORIGINAL_REPO_URL | sed 's/\//\\\//g') && \
15+
sed -i "s/$SEARCH_STRING/$REPLACE_STRING/g" /etc/apk/repositories && \
16+
gem sources --add $RUBYGEMS_SOURCE --remove https://rubygems.org/; \
17+
fi && \
18+
apk --update --no-cache add tzdata && \
19+
cp /usr/share/zoneinfo/$TZ /etc/localtime && \
20+
echo $TZ > /etc/timezone
21+
22+
# RUN gem install app_status_notification -v $APP_STATUS_NOTIFICATION_VERSION
23+
COPY pkg/app_status_notification-0.9.0.beta6.gem /tmp/
24+
RUN gem install /tmp/app_status_notification-0.9.0.beta6.gem
25+
26+
WORKDIR /app
27+
28+
VOLUME [ "/app/config" ]
29+
30+
CMD ["app_status_notification", "--config", "/app/config"]

Rakefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require 'bundler/gem_tasks'
4+
require 'app_status_notification'
5+
6+
require 'pry-byebug'
7+
require 'awesome_print'
8+
9+
require 'rspec/core/rake_task'
10+
RSpec::Core::RakeTask.new
11+
12+
require 'rubocop/rake_task'
13+
RuboCop::RakeTask.new(:rubocop)
14+
15+
task(default: %i[spec rubocop])

0 commit comments

Comments
 (0)