Updated DP001 tattler policy reference #332
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
# This is a basic workflow to help you get started with Actions | |
name: CI to Docker Hub | |
# Controls when the action will run. Triggers the workflow on push or pull request events | |
on: | |
push: | |
branches: [master, dev] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
- name: Install Docker Compose | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
docker-compose --version | |
- name: Make Cache Directory | |
run: mkdir bootstrap/cache | |
- name: Build Docker Image | |
run: docker-compose build --no-cache | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to Docker Hub (Master) | |
if: contains(github.ref, 'master') | |
run: | | |
docker tag vatusa/api vatusa/api:${{ github.sha }} | |
docker push vatusa/api:${{ github.sha }} | |
- name: Push to Docker Hub (Dev) | |
if: contains(github.ref, 'dev') | |
run: | | |
docker tag vatusa/api vatusa/api:dev-${{ github.sha }} | |
docker push vatusa/api:dev-${{ github.sha }} | |
deploy: | |
name: Deploy to ArgoCD | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
with: | |
repository: 'VATUSA/gitops' | |
path: gitops | |
token: ${{ secrets.G_TOKEN }} | |
- name: Setup Kustomize | |
uses: imranismail/setup-kustomize@v2 | |
- name: Update manifests | |
run: | | |
cd $GITHUB_WORKSPACE/gitops/current | |
kustomize edit set image vatusa/api=vatusa/api:${{ github.sha }} | |
- name: Commit and push changes | |
run: | | |
cd $GITHUB_WORKSPACE/gitops | |
git config --global user.email "[email protected]" | |
git config --global user.name "VATUSA6" | |
git add . | |
git commit -m "Update API image tag to ${{ github.sha }}" | |
- name: Push to gitops repo | |
run: | | |
cd $GITHUB_WORKSPACE/gitops | |
git push origin main |