mirror of
https://github.com/miaowware/qrm2.git
synced 2025-05-24 02:12:31 -04:00
Merge pull request #272 from miaowware/worflows-updates
add/update workflows
This commit is contained in:
commit
fa2dded81b
74
.github/workflows/docker.yml
vendored
74
.github/workflows/docker.yml
vendored
@ -1,11 +1,13 @@
|
|||||||
name: Docker Build and Push
|
# vim: ts=2 sw=2:
|
||||||
|
|
||||||
|
name: Docker Build and Deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# Publish `master` as Docker `dev` image.
|
# Publish `master` as Docker `dev` image.
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
# Publish `v*` tags as releases and as `latest`.
|
# Publish `v*` tags as x.x.x images and as `latest`.
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- v*
|
||||||
|
|
||||||
@ -13,46 +15,62 @@ env:
|
|||||||
IMAGE_NAME: qrm2
|
IMAGE_NAME: qrm2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
name: Build and push docker images
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
- name: Write ref to file
|
||||||
|
run: git rev-list -n 1 $GITHUB_REF > ./git_commit
|
||||||
|
|
||||||
- name: Build image
|
- name: Build image
|
||||||
run: |
|
run: docker build . --file Dockerfile -t $IMAGE_NAME
|
||||||
echo ${{ github.sha }} > git_commit
|
|
||||||
docker build . --file Dockerfile -t $IMAGE_NAME
|
|
||||||
|
|
||||||
- name: Log into Github Package Registry
|
- name: Log into Github Package Registry
|
||||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
|
||||||
|
|
||||||
- name: Log into Docker Hub
|
- name: Tag image
|
||||||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
|
id: tag_image
|
||||||
|
|
||||||
- name: Push image to registries
|
|
||||||
run: |
|
run: |
|
||||||
GITHUB_IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
|
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
|
||||||
DOCKER_IMAGE_ID=${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME
|
echo IMAGE_ID=$IMAGE_ID
|
||||||
|
echo ::set-output name=image_id::$IMAGE_ID
|
||||||
|
|
||||||
# Strip git ref prefix from version
|
# Strip git ref prefix from version
|
||||||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||||
|
|
||||||
# Strip "v" prefix from tag name
|
# Strip "v" prefix from tag name
|
||||||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||||
|
# if version is master, set version to dev
|
||||||
[[ "$VERSION" == "master" ]] && VERSION=dev
|
[[ "$VERSION" == "master" ]] && VERSION=dev
|
||||||
|
|
||||||
echo GITHUB_IMAGE_ID=$GITHUB_IMAGE_ID
|
|
||||||
echo DOCKER_IMAGE_ID=$DOCKER_IMAGE_ID
|
|
||||||
echo VERSION=$VERSION
|
echo VERSION=$VERSION
|
||||||
|
echo ::set-output name=version::$VERSION
|
||||||
|
|
||||||
# tag for Github Registry
|
# tag dev or x.x.x
|
||||||
docker tag $IMAGE_NAME $GITHUB_IMAGE_ID:$VERSION
|
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
|
||||||
[[ "$VERSION" != "dev" ]] && docker tag $IMAGE_NAME $GITHUB_IMAGE_ID:latest
|
# tag latest if not a dev release
|
||||||
docker push $GITHUB_IMAGE_ID
|
[[ "$VERSION" != "dev" ]] && docker tag $IMAGE_NAME $IMAGE_ID:latest
|
||||||
|
|
||||||
# tag for Docker Hub
|
- name: Push images to registry
|
||||||
docker tag $IMAGE_NAME $DOCKER_IMAGE_ID:$VERSION
|
run: docker push ${{ steps.tag_image.outputs.image_id }}
|
||||||
[[ "$VERSION" != "dev" ]] && docker tag $IMAGE_NAME $DOCKER_IMAGE_ID:latest
|
|
||||||
docker push $DOCKER_IMAGE_ID
|
# deploy:
|
||||||
|
# name: Deploy new images
|
||||||
|
# runs-on: ubuntu-20.04
|
||||||
|
# needs: docker
|
||||||
|
# steps:
|
||||||
|
# - name: Deploy official images
|
||||||
|
# id: deploy_images
|
||||||
|
# uses: satak/webrequest-action@v1.2.3
|
||||||
|
# with:
|
||||||
|
# url: ${{ secrets.DEPLOY_URL }}
|
||||||
|
# method: POST
|
||||||
|
# headers: '{"Authentication": "Token ${{ secrets.DEPLOY_TOKEN }}"}'
|
||||||
|
# payload: |
|
||||||
|
# '{
|
||||||
|
# "repository": "${{ github.repository }}",
|
||||||
|
# "version": "${{ jobs.docker.steps.tag_image.outputs.version }}"
|
||||||
|
# }'
|
||||||
|
58
.github/workflows/release.yml
vendored
Normal file
58
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# vim: ts=2 sw=2:
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# Sequence of patterns matched against refs/tags
|
||||||
|
tags:
|
||||||
|
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||||
|
|
||||||
|
name: Create Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
- name: Get Version Info
|
||||||
|
id: get_tag
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
SUBJECT=$(/usr/bin/git tag -l ${GITHUB_REF#refs/tags/} --format='%(subject)')
|
||||||
|
BODY=$(/usr/bin/git tag -l ${GITHUB_REF#refs/tags/} --format='%(body)' | sed '/-----BEGIN PGP SIGNATURE-----/,$d')
|
||||||
|
|
||||||
|
echo SUBJECT=$SUBJECT
|
||||||
|
echo BODY=$BODY
|
||||||
|
|
||||||
|
echo ::set-output name=subject::${SUBJECT}
|
||||||
|
echo ::set-output name=body::${BODY}
|
||||||
|
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
|
||||||
|
|
||||||
|
- name: Get Changelog Content
|
||||||
|
id: changelog_reader
|
||||||
|
uses: mindsers/changelog-reader-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ steps.get_tag.outputs.current_version }}
|
||||||
|
path: ./CHANGELOG.md
|
||||||
|
|
||||||
|
- name: Publish Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.changelog_reader.outputs.version }}
|
||||||
|
release_name: ${{ steps.get_tag.outputs.subject }}
|
||||||
|
body: |
|
||||||
|
${{ steps.get_tag.outputs.body }}
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
${{ steps.changelog_reader.outputs.changes }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user