Skip to content

Commit

Permalink
dont use auto populate
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyd3d committed Aug 22, 2024
1 parent d8fdabe commit 3f4b3fe
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 159 deletions.
118 changes: 48 additions & 70 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ on:
inputs:
RELEASE:
required: false
type: choice
options:
- 0.0.8-rc
- 0.0.6-rc
- 0.0.5-rc
- 0.0.4-rc
type: string
description: "The name of the release you want to deploy to stable."
pull_request:
types: [opened, reopened, synchronize]
branches:
Expand All @@ -23,8 +19,10 @@ on:
- "*"
release:
types: [created]

env:
ARTIFACT_NAME: actions-demo

jobs:
build_test_and_deploy_dev:
runs-on: ubuntu-latest
Expand All @@ -34,119 +32,99 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Get Short SHA
run: |
echo "SHA_SHORT=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: Print Short SHA
run: |
echo "Short SHA: ${{ env.SHA_SHORT }}"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Run tests
run: |
echo "Fake running some test"
- name: Build Docker Image
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: |
kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.SHA_SHORT }}
- name: Push Docker Image if merged
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev' }}
run: |
docker push kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.SHA_SHORT }}
echo "Docker image pushed with tag ${{ env.SHA_SHORT }}"
- name: Deploy to k8
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev' }}
run: |
echo "Pretending to deploy to k8"
# Build test and deploy to qa namespace when a release tag is created
build_test_and_deploy_qa:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Get Tag Name
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
# Validate and sanitize the tag name
if [[ ! "$TAG_NAME" =~ ^[a-z0-9]+([._-][a-z0-9]+)*$ ]]; then
echo "Invalid tag name: $TAG_NAME. Tag names must be lowercase and can include dashes, dots, or underscores."
exit 1
fi
# Ensure tag name is a valid Docker tag
if [ ${#TAG_NAME} -gt 128 ]; then
echo "Tag name is too long. Must be less than 128 characters."
exit 1
fi
TAG_COMMIT_SHA=$(git rev-list -n 1 $TAG_NAME)
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "TAG_COMMIT_SHA=$TAG_COMMIT_SHA" >> $GITHUB_ENV
echo "SHA_SHORT=$(echo $TAG_COMMIT_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: Print Tag Name and SHA
run: |
echo "Tag Name: ${{ env.TAG_NAME }}"
echo "Full SHA: ${{ env.TAG_COMMIT_SHA }}"
echo "Short SHA: ${{ env.SHA_SHORT }}"

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull Docker Image for QA
run: |
docker pull kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.SHA_SHORT }}
- name: Retag Docker Image with Tag Name

- name: Check if release tag's SHA is in artifactory
run: |
echo "Retagging image tag to: ${{ env.TAG_NAME }}"
docker tag kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.SHA_SHORT }} kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.TAG_NAME }}
docker images | grep kennyd3d/${{ env.ARTIFACT_NAME }} # List Docker images to verify retagging
- name: Push Retagged Docker Image
run: |
echo "Pushing the retagged image to Docker Hub"
docker push kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.TAG_NAME }}
- name: Run regression tests
run: |
echo "Fake run of regression testing"
- name: Deploy to QA k8
TAG_COMMIT_SHA=$(git rev-list -n 1 $TAG_NAME)
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "TAG_COMMIT_SHA=$TAG_COMMIT_SHA" >> $GITHUB_ENV
echo "SHA_SHORT=$(echo $TAG_COMMIT_SHA | cut -c1-7)" >> $GITHUB_ENV
if ! docker pull kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.SHA_SHORT }}; then
echo "❌ Failed to pull Docker image kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.SHA_SHORT }}" >> $GITHUB_STEP_SUMMARY
exit 1
else
- name: Retag and push Docker Image with Release Name
run: |
echo \"Retagging image tag to: ${{ github.event.release.name }}"
docker tag kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.SHORT_SHA }} kennyd3d/${{ env.ARTIFACT_NAME }}:${{ github.event.release.name }}
docker images # List Docker images to verify retagging\n"
docker push kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.RELEASE_NAME }}
- name: Deploy to Stable k8
run: |
echo "Fake deploy to QA k8 using image kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.TAG_NAME }}"
build_test_and_deploy_stable:
echo "Test to deploy to Stable k8 using image kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.RELEASE_NAME }}"
# Manually deploy the release given the release name
deploy_stable:
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'created'
if: ${{ github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get Release Tag Name
run: |
echo "RELEASE_TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
echo "RELEASE_NAME=${{ github.event.release.name }}" >> $GITHUB_ENV
- name: Print Release Tag Name and Release Name
run: |
echo "Release Tag Name: ${{ env.RELEASE_TAG_NAME }}"
echo "Release Name: ${{ env.RELEASE_NAME }}"
- name: Pull Docker Image for Stable
run: |
docker pull kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.RELEASE_TAG_NAME }}
- name: Retag Docker Image with Release Name
run: "echo \"Retagging image tag to: ${{ env.RELEASE_NAME }}\" \ndocker tag kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.RELEASE_TAG_NAME }} kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.RELEASE_NAME }}\ndocker images # List Docker images to verify retagging\n"
- name: Push Retagged Docker Image

- name: Check if release is in artifactory
run: |
echo "Pushing the retagged image to Docker Hub"
docker push kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.RELEASE_NAME }}
docker images # List Docker images to verify retagging
if docker manifest inspect ${{ github.event.release.name }} > /dev/null 2>&1; then
echo echo '# 🎊 Successfully Deployed to Stable' >> $GITHUB_STEP_SUMMARY
else
echo echo '# ❌ Failed Stable Deployment: Release not found in artifactory' >> $GITHUB_STEP_SUMMARY
exit 1
fi
- name: Deploy to Stable k8
run: |
echo "Test to deploy to Stable k8 using image kennyd3d/${{ env.ARTIFACT_NAME }}:${{ env.RELEASE_NAME }}"
echo "Test to deploy to Stable k8 using image kennyd3d/${{ env.ARTIFACT_NAME }}:${{ github.event.release.name }}"
39 changes: 0 additions & 39 deletions .github/workflows/populate-option-value.sh

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/populate.yml

This file was deleted.

0 comments on commit 3f4b3fe

Please sign in to comment.