Merge pull request #63 from sadok-f/dependabot/github_actions/actions… #88
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected] | |
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/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag_prefix: "" | |
release_branches: main | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
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 "[email protected]" | |
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 }} |