31 lines
1.0 KiB
YAML
31 lines
1.0 KiB
YAML
name: Build and Push Docker Image then Slack webhook
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # Change this if needed
|
|
pull_request:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
run: echo "${{ secrets.REGISTRY_TOKEN_GITEA }}" | docker login git.adaptcentre.ie -u "${{ secrets.USERNAME_GITEA }}" --password-stdin
|
|
|
|
- name: Build Docker image
|
|
run: docker build -t ${{ secrets.DOCKER_IMAGE_NAME }} .
|
|
|
|
- name: Push Docker image to Gitea Registry
|
|
run: docker push ${{ secrets.DOCKER_IMAGE_NAME }}
|
|
|
|
slack-notification:
|
|
needs: build-and-push
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Send Slack notification
|
|
run: |
|
|
curl -X POST -H 'Content-type: application/json' --data '{"text": "Image build for ${{ gitea.repository }} on branch ${{ gitea.ref }} completed with status: ${{ needs.build-and-push.result }}."}' "${{ secrets.SLACK_WEBHOOK_URL }}" |