Add github actions to build next

This commit is contained in:
Xiaonan Shen
2021-09-05 02:59:57 +08:00
parent 9c56bb2861
commit 7b72698ad5
5 changed files with 27 additions and 97 deletions

View File

@@ -1,80 +0,0 @@
name: pack from deb
on:
push:
branches:
- master
- dev
paths:
- .github/workflows/deb.yaml
- deb/*
pull_request:
paths:
- .github/workflows/deb.yaml
- deb/*
env:
DOCKER_REPO: shenxn/protonmail-bridge
DOCKER_REPO_DEV: ghcr.io/shenxn/protonmail-bridge-dev
jobs:
deb:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Set version
id: version
run: echo "::set-output name=version::`cat deb/VERSION`"
- name: Set repo
id: repo
run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ steps.repo.outputs.repo }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build image without push
uses: docker/build-push-action@v2
with:
context: ./deb
file: ./deb/Dockerfile
load: true
tags: protonmail-bridge:latest
- name: Scan image
id: scan
uses: anchore/scan-action@v2
with:
image: protonmail-bridge:latest
fail-build: true
severity-cutoff: critical
acs-report-enable: true
- name: Upload Anchore scan SARIF report
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
- name: Login to DockerHub
uses: docker/login-action@v1
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Push image
uses: docker/build-push-action@v2
with:
context: ./deb
file: ./deb/Dockerfile
tags: |
${{ steps.repo.outputs.repo }}:latest
${{ steps.repo.outputs.repo }}:${{ steps.version.outputs.version }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}

View File

@@ -1,21 +1,24 @@
name: build from source name: build next
on: on:
push: push:
branches: branches:
- master - next
- dev
paths: paths:
- .github/workflows/build.yaml - .github/workflows/next.yaml
- build/* - docker/*
- protonmail_version/*
- VERSION
pull_request: pull_request:
paths: paths:
- .github/workflows/build.yaml - .github/workflows/next.yaml
- build/* - docker/*
- protonmail_version/*
- VERSION
env: env:
DOCKER_REPO: shenxn/protonmail-bridge DOCKER_REPO: shenxn/protonmail-bridge-ng
DOCKER_REPO_DEV: ghcr.io/shenxn/protonmail-bridge-dev DOCKER_REPO_DEV: ghcr.io/shenxn/protonmail-bridge-ng-dev
PLATFORMS: linux/amd64,linux/arm64/v8 PLATFORMS: linux/amd64,linux/arm64/v8
jobs: jobs:
@@ -31,7 +34,9 @@ jobs:
uses: actions/checkout@master uses: actions/checkout@master
- name: Set version - name: Set version
id: version id: version
run: echo "::set-output name=version::`cat build/VERSION`" run: |
echo "::set-output name=image_version::$(cat VERSION)" && \
echo "::set-output name=protonmail_bridge_version::$(cat protonmail_bridge_version/VERSION_LATEST)"
- name: Set repo - name: Set repo
id: repo id: repo
run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi run: if [[ $GITHUB_REF == "refs/heads/master" ]]; then echo "::set-output name=repo::${DOCKER_REPO}"; else echo "::set-output name=repo::${DOCKER_REPO_DEV}"; fi
@@ -49,8 +54,9 @@ jobs:
- name: Build image without push to registry - name: Build image without push to registry
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./build context: ./docker
file: ./build/Dockerfile file: ./docker/Dockerfile
build-args: PROTONMAIL_BRIDGE_VERSION=${{ steps.version.outputs.protonmail_bridge_version }}
platforms: ${{ env.PLATFORMS }} platforms: ${{ env.PLATFORMS }}
push: true push: true
tags: localhost:5000/protonmail-bridge:latest tags: localhost:5000/protonmail-bridge:latest
@@ -74,7 +80,7 @@ jobs:
password: ${{ secrets.REGISTRY_PASSWORD }} password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v1 uses: docker/login-action@v1
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' }} if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/next' }}
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
@@ -82,11 +88,12 @@ jobs:
- name: Push image - name: Push image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./build context: ./docker
file: ./build/Dockerfile file: ./docker/Dockerfile
build-args: PROTONMAIL_BRIDGE_VERSION=${{ steps.version.outputs.protonmail_bridge_version }}
platforms: ${{ env.PLATFORMS }} platforms: ${{ env.PLATFORMS }}
tags: | tags: |
${{ steps.repo.outputs.repo }}:build ${{ steps.repo.outputs.repo }}:latest
${{ steps.repo.outputs.repo }}:${{ steps.version.outputs.version }}-build ${{ steps.repo.outputs.repo }}:${{ steps.version.outputs.image_version }}-${{ steps.version.outputs.protonmail_bridge_version }}
labels: ${{ steps.docker_meta.outputs.labels }} labels: ${{ steps.docker_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}

1
VERSION Normal file
View File

@@ -0,0 +1 @@
0.1

View File

@@ -0,0 +1 @@
v1.8.7

View File

@@ -0,0 +1 @@
v1.8.9