Merge pull request #969 from simple-login/ac-push-on-tag

GH Actions refactor
This commit is contained in:
Adrià Casajús 2022-05-12 09:57:09 +02:00 committed by GitHub
commit b17af67614
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 }}