Skip to content

initial commit

initial commit #1

name: Build Container Image
on:
workflow_dispatch:
push:
branches: ['main']
paths:
- 'src/**'
# pull_request:
# branches: ['main']
jobs:
# ------------------------------------------ job 1
build-and-publish:
runs-on: ubuntu-latest
outputs:
newtag: ${{ steps.export_tag.outputs.sha }}
shorttag: ${{ steps.export_tag.outputs.short }}
steps:
- name: Export sha as short tag
id: export_tag
run: |
export "SHA=${{ github.sha }}"
echo $SHA
echo "${SHA:0:7}"
export "SHORT=${SHA:0:7}"
echo "sha=${{github.sha}}" >> $GITHUB_OUTPUT
echo "short=${SHORT}" >> $GITHUB_OUTPUT
- name: Build, Tag and Push Docker Image to GHCR
uses: GlueOps/[email protected]
# ------------------------------------------ job 2
update-deployed-image-tag:
runs-on: ubuntu-latest
needs: build-and-publish
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
repository: xgeekshq/sxmp-api-todolist_deployment
token: ${{ secrets.IDP_TOKEN_G }}
- name: Install Kustomize
uses: imranismail/setup-kustomize@v2
- name: Kustomize deployment image tag
env:
NEW_TAG: ${{ needs.build-and-publish.outputs.newtag }}
SHORT_TAG: ${{ needs.build-and-publish.outputs.shorttag }}
run: |
cd k8s/overlays/dev
echo $NEW_TAG
echo $SHORT_TAG
kustomize edit set image ghcr.io/xgeekshq/sxmp-api-todolist:${{ env.SHORT_TAG }}
git config --local user.email "[email protected]"
git config --local user.name "CD Action"
git add .
git commit -m "ci: update 'sxmp-api-todolist' image tag to '${{ env.SHORT_TAG }}' "
git push