Build and Push PHP ACTUAL #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Images | |
# Tento workflow se spustí při každém pushi do hlavní větve nebo dle plánovaného cron jobu | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * *' # Spustí denní build každý den v 00:00 UTC | |
workflow_dispatch: # Umožní manuální spuštění z GitHub UI | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout repozitář | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Přihlášení do Docker Hubu | |
- name: Log in to Docker Hub | |
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
# Build and Push Docker images | |
- name: Build and push Docker images | |
run: | | |
for version in 8.2 8.3 8.3-fpm-nginx; do | |
docker build -t massimofilippi/php:$version ./$version | |
docker push massimofilippi/php:$version | |
done | |
# # Build Docker image | |
# - name: Build Docker image | |
# run: docker build -t massimofilippi/php:8.2 ./8.2 | |
# # run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/my-image:latest . | |
# | |
# # Push Docker image do Docker Hubu | |
# - name: Push Docker image | |
# run: docker push massimofilippi/php:8.2 | |
# # run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/my-image:latest | |
# Slack notifikace o úspěšném buildu | |
- name: Notify Slack of build status | |
if: success() | |
run: | | |
curl -X POST -H 'Content-type: application/json' --data '{"text":"Docker images build and push succeeded for all PHP versions!"}' ${{ secrets.SLACK_WEBHOOK_URL }} | |
# Slack notifikace o neúspěšném buildu | |
- name: Notify Slack of build failure | |
if: failure() | |
run: | | |
curl -X POST -H 'Content-type: application/json' --data '{"text":"Docker images build or push failed for one or more PHP versions!"}' ${{ secrets.SLACK_WEBHOOK_URL }} |