Skip to content

update main

update main #128

Workflow file for this run

name: Build
on:
workflow_dispatch:
pull_request:
types:
- closed
branches:
- main
- dev
env:
SERVICE_NAME: rpkm67-gateway
IMAGE_NAME: ghcr.io/${{ github.repository }}
IMAGE_TAG: <WILL_BE_SET>
jobs:
build:
name: Build
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
outputs:
IMAGE_TAG: ${{ steps.tag_action.outputs.new_tag }}
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Bump version and push tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
RELEASE_BRANCHES: dev
DEFAULT_BUMP: patch
id: tag_action
- name: Set IMAGE_TAG
run: echo "IMAGE_TAG=${{ steps.tag_action.outputs.new_tag }}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
cd:
name: Continuous Deployment
needs: build
runs-on: ubuntu-latest
env:
IMAGE_TAG: ${{ needs.build.outputs.IMAGE_TAG }}
steps:
- name: Checkout DevOps repository
uses: actions/checkout@v4
with:
repository: isd-sgcu/rpkm67-devops
token: ${{ secrets.RPKM67_DEVOPS_TOKEN }}
- name: Update image tag in dev
uses: mikefarah/yq@master
with:
cmd: yq -i '.[0].value = "${{ env.IMAGE_NAME }}:" + strenv(IMAGE_TAG)' isd/${{ env.SERVICE_NAME }}/deployment.yaml
- name: Update image tag in prod
uses: mikefarah/yq@master
if: github.ref == 'refs/heads/main'
with:
cmd: yq -i '.[0].value = "${{ env.IMAGE_NAME }}:" + strenv(IMAGE_TAG)' prod/${{ env.SERVICE_NAME }}/deployment.yaml
- name: Commit & Push changes
uses: actions-js/[email protected]
with:
repository: isd-sgcu/rpkm67-devops
github_token: ${{ secrets.RPKM67_DEVOPS_TOKEN }}