Skip to content

Commit

Permalink
Feat/deploy afn k8s (#41)
Browse files Browse the repository at this point in the history
Allow to deploy via PR to afn-k8s
  • Loading branch information
julsemaan authored Mar 23, 2024
1 parent e888714 commit 216cd7c
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 7 deletions.
48 changes: 47 additions & 1 deletion .github/workflows/docker-admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ on:
jobs:
docker:
runs-on: ubuntu-latest
outputs:
img_tag: ${{ steps.preserve_img_tag.outputs.img_tag }}
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Setup VARS.js
run: 'printf "$ADMIN_VARS" > admin/js/VARS.js'
Expand All @@ -24,6 +26,11 @@ jobs:
run: |
echo "IMG_TAG=$(echo ${GITHUB_SHA} | sed -E 's/refs\/(heads|tags)\///g' | sed -e 's/\//-/g')" >> $GITHUB_ENV
- name: Preserve image tag
id: preserve_img_tag
run: |
echo "img_tag=${{ env.IMG_TAG }}" >> $GITHUB_OUTPUT
- name: Kaniko build
uses: julsemaan/action-kaniko@master
with:
Expand All @@ -35,4 +42,43 @@ jobs:
path: admin/
extra_args: >-
--push-retry 5
pr_afn_k8s:
concurrency:
group: prs-to-afn-k8s
cancel-in-progress: false
needs: docker
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: julsemaan/afn-k8s
token: ${{ secrets.GHA_REPO_TOKEN }}
fetch-depth: 0

- uses: frenck/action-setup-yq@v1

- name: PR tag change to afn-k8s
env:
IMG_TAG: ${{needs.docker.outputs.img_tag}}
GH_TOKEN: ${{ secrets.GHA_REPO_TOKEN }}
CHANGE_TYPE: admin
run: |
BRANCH_ID=`date "+%Y%m%d"`
BRANCH_NAME=tmp/$BRANCH_ID
# Checkout the remote ref if it already exist, otherwise, start from main
git checkout origin/$BRANCH_NAME || true
git checkout -b $BRANCH_NAME
yq -i '.lb.'$CHANGE_TYPE'.image.tag = "'$IMG_TAG'"' charts/afn/values.yaml
git config --global user.email "devnull@semaan.ca"
git config --global user.name "Semaan Bot"
git commit --allow-empty -a -m "bump $CHANGE_TYPE to $IMG_TAG"
git push origin HEAD
(gh pr list --state open --limit 1 --head $BRANCH_NAME | grep $BRANCH_NAME) || \
gh pr create -B main -H $BRANCH_NAME --title "Update images $BRANCH_ID" --body 'Created by Github action'
4 changes: 2 additions & 2 deletions .github/workflows/docker-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Kaniko build
uses: julsemaan/action-kaniko@master
with:
Expand All @@ -30,7 +30,7 @@ jobs:
if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/production'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Use staging target servers if necessary
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-client-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Kaniko build
uses: julsemaan/action-kaniko@master
with:
Expand Down
71 changes: 70 additions & 1 deletion .github/workflows/docker-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ on:
jobs:
docker:
runs-on: ubuntu-latest
outputs:
img_tag: ${{ steps.preserve_img_tag.outputs.img_tag }}
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Setup VARS.js
run: 'printf "$AFN_VARS" > client/assets/js/VARS.js'
Expand All @@ -25,6 +27,11 @@ jobs:
run: |
echo "IMG_TAG=$(echo ${GITHUB_SHA} | sed -E 's/refs\/(heads|tags)\///g' | sed -e 's/\//-/g')" >> $GITHUB_ENV
- name: Preserve image tag
id: preserve_img_tag
run: |
echo "img_tag=${{ env.IMG_TAG }}" >> $GITHUB_OUTPUT
- name: Kaniko build full
uses: julsemaan/action-kaniko@master
with:
Expand Down Expand Up @@ -55,3 +62,65 @@ jobs:
--push-retry 5
--build-arg=SRC_IMAGE=ghcr.io/julsemaan/anyfile-notepad/client-full:${{ env.IMG_TAG }}
pr_afn_k8s:
needs: docker
concurrency:
group: prs-to-afn-k8s
cancel-in-progress: false
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: julsemaan/afn-k8s
token: ${{ secrets.GHA_REPO_TOKEN }}
fetch-depth: 0

- uses: frenck/action-setup-yq@v1

- name: PR tag change to afn-k8s
env:
IMG_TAG: ${{needs.docker.outputs.img_tag}}
GH_TOKEN: ${{ secrets.GHA_REPO_TOKEN }}
CHANGE_TYPE: appProdImage
run: |
BRANCH_ID=`date "+%Y%m%d"`
BRANCH_NAME=tmp/$BRANCH_ID
# Checkout the remote ref if it already exist, otherwise, start from main
git checkout origin/$BRANCH_NAME || true
git checkout -b $BRANCH_NAME
yq -i '.backend.'$CHANGE_TYPE'.tag = "'$IMG_TAG'"' charts/afn/values.yaml
git config --global user.email "devnull@semaan.ca"
git config --global user.name "Semaan Bot"
git commit --allow-empty -a -m "bump $CHANGE_TYPE to $IMG_TAG"
git push origin HEAD
(gh pr list --state open --limit 1 --head $BRANCH_NAME | grep $BRANCH_NAME) || \
gh pr create -B main -H $BRANCH_NAME --title "Update images $BRANCH_ID" --body 'Created by Github action'
#TODO: shouldn´t be pushing the same image for prod/dev client
- name: PR tag change to afn-k8s
env:
IMG_TAG: ${{needs.docker.outputs.img_tag}}
GH_TOKEN: ${{ secrets.GHA_REPO_TOKEN }}
CHANGE_TYPE: appDevImage
run: |
BRANCH_ID=`date "+%Y%m%d"`
BRANCH_NAME=tmp/$BRANCH_ID
# The branch already exists from the previous step
git checkout $BRANCH_NAME
yq -i '.backend.'$CHANGE_TYPE'.tag = "'$IMG_TAG'"' charts/afn/values.yaml
git config --global user.email "devnull@semaan.ca"
git config --global user.name "Semaan Bot"
git commit --allow-empty -a -m "bump $CHANGE_TYPE to $IMG_TAG"
git push origin HEAD
(gh pr list --state open --limit 1 --head $BRANCH_NAME | grep $BRANCH_NAME) || \
gh pr create -B main -H $BRANCH_NAME --title "Update images $BRANCH_ID" --body 'Created by Github action'
48 changes: 47 additions & 1 deletion .github/workflows/docker-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ on:
jobs:
docker:
runs-on: ubuntu-latest
outputs:
img_tag: ${{ steps.preserve_img_tag.outputs.img_tag }}
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Compute image tag
run: |
echo "IMG_TAG=$(echo ${GITHUB_SHA} | sed -E 's/refs\/(heads|tags)\///g' | sed -e 's/\//-/g')" >> $GITHUB_ENV
- name: Preserve image tag
id: preserve_img_tag
run: |
echo "img_tag=${{ env.IMG_TAG }}" >> $GITHUB_OUTPUT
- name: Kaniko build full
uses: julsemaan/action-kaniko@master
with:
Expand All @@ -31,3 +38,42 @@ jobs:
extra_args: >-
--push-retry 5
pr_afn_k8s:
needs: docker
concurrency:
group: prs-to-afn-k8s
cancel-in-progress: false
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: julsemaan/afn-k8s
token: ${{ secrets.GHA_REPO_TOKEN }}
fetch-depth: 0

- uses: frenck/action-setup-yq@v1

- name: PR tag change to afn-k8s
env:
IMG_TAG: ${{needs.docker.outputs.img_tag}}
GH_TOKEN: ${{ secrets.GHA_REPO_TOKEN }}
CHANGE_TYPE: pages
run: |
BRANCH_ID=`date "+%Y%m%d"`
BRANCH_NAME=tmp/$BRANCH_ID
# Checkout the remote ref if it already exist, otherwise, start from main
git checkout origin/$BRANCH_NAME || true
git checkout -b $BRANCH_NAME
yq -i '.lb.'$CHANGE_TYPE'.image.tag = "'$IMG_TAG'"' charts/afn/values.yaml
git config --global user.email "devnull@semaan.ca"
git config --global user.name "Semaan Bot"
git commit --allow-empty -a -m "bump $CHANGE_TYPE to $IMG_TAG"
git push origin HEAD
(gh pr list --state open --limit 1 --head $BRANCH_NAME | grep $BRANCH_NAME) || \
gh pr create -B main -H $BRANCH_NAME --title "Update images $BRANCH_ID" --body 'Created by Github action'
47 changes: 46 additions & 1 deletion .github/workflows/docker-webserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ on:
jobs:
docker:
runs-on: ubuntu-latest
outputs:
img_tag: ${{ steps.preserve_img_tag.outputs.img_tag }}
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Compute image tag
run: |
echo "IMG_TAG=$(echo ${GITHUB_SHA} | sed -E 's/refs\/(heads|tags)\///g' | sed -e 's/\//-/g')" >> $GITHUB_ENV
- name: Preserve image tag
id: preserve_img_tag
run: |
echo "img_tag=${{ env.IMG_TAG }}" >> $GITHUB_OUTPUT
- name: Kaniko build
uses: julsemaan/action-kaniko@master
with:
Expand All @@ -31,3 +38,41 @@ jobs:
path: webserver/
extra_args: --push-retry 5

pr_afn_k8s:
needs: docker
concurrency:
group: prs-to-afn-k8s
cancel-in-progress: false
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: julsemaan/afn-k8s
token: ${{ secrets.GHA_REPO_TOKEN }}
fetch-depth: 0

- uses: frenck/action-setup-yq@v1

- name: PR tag change to afn-k8s
env:
IMG_TAG: ${{needs.docker.outputs.img_tag}}
GH_TOKEN: ${{ secrets.GHA_REPO_TOKEN }}
run: |
BRANCH_ID=`date "+%Y%m%d"`
BRANCH_NAME=tmp/$BRANCH_ID
# Checkout the remote ref if it already exist, otherwise, start from main
git checkout origin/$BRANCH_NAME || true
git checkout -b $BRANCH_NAME
yq -i '.backend.image.tag = "'$IMG_TAG'"' charts/afn/values.yaml
git config --global user.email "devnull@semaan.ca"
git config --global user.name "Semaan Bot"
git commit --allow-empty -a -m "bump $CHANGE_TYPE to $IMG_TAG"
git push origin HEAD
(gh pr list --state open --limit 1 --head $BRANCH_NAME | grep $BRANCH_NAME) || \
gh pr create -B main -H $BRANCH_NAME --title "Update images $BRANCH_ID" --body 'Created by Github action'

0 comments on commit 216cd7c

Please sign in to comment.