mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 07:31:12 +01:00
Merge pull request #969 from simple-login/ac-push-on-tag
GH Actions refactor
This commit is contained in:
commit
b17af67614
1 changed files with 37 additions and 9 deletions
46
.github/workflows/main.yml
vendored
46
.github/workflows/main.yml
vendored
|
@ -1,9 +1,12 @@
|
|||
name: Run tests & Publish to Docker Registry
|
||||
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
types: [ 'opened' ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
max-parallel: 4
|
||||
|
@ -93,17 +96,35 @@ jobs:
|
|||
name: code-coverage-report
|
||||
path: htmlcov
|
||||
|
||||
- name: Publish to Docker Registry
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
uses: docker/build-push-action@v1
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: ['test']
|
||||
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
|
||||
|
||||
steps:
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: simplelogin/app-ci
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
repository: simplelogin/app-ci
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
tag_with_ref: true
|
||||
|
||||
- name: Build image and publish to Docker Registry
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
# We need to checkout the repository in order for the "Create Sentry release" to work
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Create Sentry release
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
uses: getsentry/action-release@v1
|
||||
env:
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
|
@ -111,9 +132,16 @@ jobs:
|
|||
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
||||
|
||||
- name: Send Telegram message
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
uses: appleboy/telegram-action@master
|
||||
with:
|
||||
to: ${{ secrets.TELEGRAM_TO }}
|
||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||
args: Docker image pushed on ${{ github.ref }}
|
||||
|
||||
- name: Post notification to Slack
|
||||
uses: slackapi/slack-github-action@v1.19.0
|
||||
with:
|
||||
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
|
||||
slack-message: "New tag generated: ${{github.ref}}\nBuild result: ${{ job.status }}"
|
||||
env:
|
||||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
|
||||
|
|
Loading…
Reference in a new issue