Skip to content

Commit

Permalink
Add file to build images
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosribas committed May 7, 2024
1 parent 5f14a9b commit 6eab591
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Build image to GitHub Packages

name: Building Docker containers

# Triggers the workflow on push events
on:
push:
paths-ignore:
- 'ansible/**'
- 'kubernetes/**'
- 'nginx/**'
- 'terraform/**'

jobs:
initial-notification:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Initial notification
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
env:
SLACK_MESSAGE: 'Publishing image to GitHub Packages'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true

push-image-to-github:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96
with:
images: ghcr.io/${{ github.repository }}

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

final-notification:
runs-on: ubuntu-latest
needs: [push_image_to_dockerhub, push_image_to_github]
steps:
- uses: actions/checkout@v3

- name: Final notification
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
env:
SLACK_MESSAGE: 'New image pushed to GitHub Packages'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true

0 comments on commit 6eab591

Please sign in to comment.