-
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.
Signed-off-by: Tyler Marques <[email protected]>
- Loading branch information
1 parent
011e415
commit 7a90b5b
Showing
1 changed file
with
18 additions
and
19 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 |
---|---|---|
|
@@ -3,26 +3,20 @@ name: Build and Publish Docker Image | |
on: | ||
push: | ||
branches: | ||
- dev | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: github-actions | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
|
@@ -32,29 +26,34 @@ jobs: | |
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
uses: docker/build-push-action@v5 | ||
with: | ||
permissions: write-all | ||
context: . | ||
push: true | ||
tags: ghcr.io/tylermarques/u-the-bomb-com:dev | ||
tags: ghcr.io/tylermarques/u-the-bomb-com:${{ github.sha }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
update-manifests: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
environment: github-actions | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: tylermarques/homelab-infra | ||
ref: main | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
token: ${{ secrets.HOMELAB_GITHUB_PAT }} | ||
path: homelab-infra/ | ||
|
||
- name: Update Manifests | ||
run: | | ||
cd homelab-infra | ||
ls -lha | ||
apt update && apt install -y yq | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
yq e '(.images[] | select(.name == "u-the-bomb-com") | .newTag) = "'${{ github.sha }}'"' apps/u-the-bomb-com/dev/kustomization.yaml -i | ||
git commit -am 'Increment image tag' | ||
git commit -m "Update manifests" | ||
yq e '(.images[] | select(.name == "u-the-bomb-com") | .newTag) = "'${{ github.sha }}'"' apps/u-the-bomb-com/production/kustomization.yaml -i | ||
git commit -am 'Push from ${{ github.actor }} to ${{ github.repository }}' | ||
git push |