-
Notifications
You must be signed in to change notification settings - Fork 3
45 lines (40 loc) · 1.21 KB
/
Docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Docker
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
REGISTRY_NAME: hexletbasics
CI: true
COLOR_MAP: '{ success: "#008000", failure: "#800000" }'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check image building
run: docker build .
build-push-notify:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
needs: build
steps:
- uses: actions/checkout@v4
- name: Set repository name
run: |
echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}')" >> $GITHUB_ENV
- name: Build and push into docker hub
uses: docker/build-push-action@v5
with:
repository: ${{ env.REGISTRY_NAME }}/${{ env.REPOSITORY_NAME }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tags: latest
- name: Send notification into Slack
if: ${{ always() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ fromJson(env.COLOR_MAP)[job.status] }}
SLACK_TITLE: ${{ job.status }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}