Skip to content

Merge pull request #67 from sadok-f/dependabot/github_actions/mathieu… #92

Merge pull request #67 from sadok-f/dependabot/github_actions/mathieu…

Merge pull request #67 from sadok-f/dependabot/github_actions/mathieu… #92

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.tag_version.outputs.new_tag }}
strategy:
matrix:
node-version: [14.x]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ""
release_branches: main
- name: Build and push Docker image
uses: docker/build-push-action@v5.2.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
repository: ${{ secrets.DOCKER_USERNAME }}/hello-world-cicd
tags: ${{ steps.tag_version.outputs.new_tag }}, latest
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v2
with:
kustomize-version: "3.6.1"
- name: Update Kubernetes resources
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
cd kustomize/base
kustomize edit set image hello-world-cicd=$DOCKER_USERNAME/hello-world-cicd:${{ needs.build.outputs.new_tag }}
cat kustomization.yml
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "Bump docker tag"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}