fix CVEs #117
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: Docker Build | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- src/** | |
- Dockerfile | |
- docker.version | |
jobs: | |
validate-bump: | |
runs-on: ubuntu-latest | |
outputs: | |
bumped: ${{ steps.changed-files.outputs.any_changed }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Verify Version file Changed | |
uses: tj-actions/changed-files@v34 | |
id: changed-files | |
with: | |
files: | | |
docker.version | |
test-go: | |
runs-on: ubuntu-latest | |
outputs: | |
passed: ${{ steps.tests.outputs.result }} | |
needs: validate-bump | |
if: needs.validate-bump.outputs.bumped == 'true' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19.3 | |
- name: Run Tests | |
id: tests | |
working-directory: ./src | |
env: | |
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} | |
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
run: | | |
if [[ $(expr $(go test --json ./... | grep Failed | wc -w)) > 0 ]]; then | |
echo "result=false" >> $GITHUB_OUTPUT | |
else | |
echo "result=true" >> $GITHUB_OUTPUT | |
fi | |
docker: | |
runs-on: ubuntu-latest | |
outputs: | |
docker_version: ${{ steps.docker_version.outputs.content }} | |
if: needs.test-go.outputs.passed == 'true' | |
needs: test-go | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Read version | |
uses: juliangruber/read-file-action@v1 | |
id: docker_version | |
with: | |
path: docker.version | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: yuvalpress/version-notifier:latest, yuvalpress/version-notifier:${{ steps.docker_version.outputs.content }} | |
helm-update: | |
runs-on: ubuntu-latest | |
needs: docker | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Configure yq | |
uses: mikefarah/yq@v4.30.1 | |
- name: Edit version attributes of the helm chart | |
run: | | |
yq -i '.appVersion = "${{ needs.docker.outputs.docker_version }}"' charts/version-notifier/Chart.yaml | |
- name: Commit Helm Chart | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "$GITHUB_ACTOR@gmail.com" | |
git commit -am "Bot: Automated Helm Chart Bump" | |
- name: Push Changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.REPO_TOKEN }} | |
branch: main |