-
Notifications
You must be signed in to change notification settings - Fork 1
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
523b932
commit c553fa7
Showing
14 changed files
with
164 additions
and
441 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
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
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 |
---|---|---|
@@ -1,110 +1,32 @@ | ||
name: publish-and-promote | ||
name: promote | ||
on: | ||
push: | ||
tags: | ||
- v*.*.* | ||
jobs: | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
packages: write | ||
contents: write | ||
|
||
steps: | ||
|
||
- name: downcase REPO | ||
run: | | ||
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | ||
# - name: use REPO | ||
# run: echo "The value of REPO is: ${{ env.REPO }}" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ env.REPO }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache | ||
cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max | ||
|
||
- name: Build and push integration tests docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./jest.integration.Dockerfile | ||
push: true | ||
tags: | | ||
ghcr.io/${{ env.REPO }}-integration-tests:${{ github.ref_name }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}-integration-tests:buildcache | ||
cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}-integration-tests:buildcache,mode=max | ||
|
||
promote: | ||
needs: publish | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout production environment | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: cloudnativeentrepreneur/example-prod-env | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
|
||
- name: Update prod environment | ||
uses: mikefarah/yq@master | ||
with: | ||
cmd: yq -i '.spec.source.targetRevision = "${{ github.ref_name }}"' helm/templates/${{ github.event.repository.name }}.yaml | ||
|
||
- name: Commit Prod Env Changes | ||
run: | | ||
if output=$(git status --porcelain) && [ -z "$output" ]; then | ||
# Working directory clean | ||
echo "No changes to commit" | ||
else | ||
# Uncommitted changes | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git add -A | ||
git commit -m "feat: Promoting ${{ github.event.repository.name }} to ${{ github.ref_name }}" | ||
fi | ||
jobs: | ||
|
||
- name: Push prod | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GH_ORG_TOKEN }} | ||
repository: cloudnativeentrepreneur/example-prod-env | ||
publish-container: | ||
uses: CloudNativeEntrepreneur/actions/.github/workflows/publish-container.yaml@main | ||
secrets: inherit | ||
with: | ||
integrationTestsContainer: true | ||
|
||
promote-local: | ||
uses: CloudNativeEntrepreneur/actions/.github/workflows/gitops-promote-helm.yaml@main | ||
secrets: inherit | ||
with: | ||
environment_repository: CloudNativeEntrepreneur/example-local-env | ||
project: example-local-env | ||
pull_request: true | ||
values: | | ||
# Set from promote job of CloudNativeEntrepreneur/example-todo-model-service | ||
local: true | ||
promote-prod: | ||
uses: CloudNativeEntrepreneur/actions/.github/workflows/gitops-promote-helm.yaml@main | ||
secrets: inherit | ||
with: | ||
environment_repository: CloudNativeEntrepreneur/example-prod-env | ||
project: example-prod-env | ||
pull_request: true |
Oops, something went wrong.