-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f14a9b
commit 6eab591
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
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 |