Merge pull request #718 from fsargent/remove-fadein #387
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: Build, push, and deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-push-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# We have to do this to workaround these errors: | |
# ERROR: failed to configure registry cache importer: invalid reference format: repository name must be lowercase | |
- name: Create REPO env var that contains lowercase github.repository name | |
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | |
- name: Docker Metadata action | |
uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
images: | | |
ghcr.io/${{ env.REPO }} | |
# Using `branch` to give a predictable name to cache from, and using | |
# `sha` so we always have a unique tag which will trigger | |
# star-server-infra terraform to run. | |
tags: | | |
type=ref,event=branch | |
type=sha | |
- name: Docker Setup Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v5 | |
with: | |
cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:${{ github.ref_name }} | |
cache-to: type=inline | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
# TODO: Currently using a personal access token to do this, which is not | |
# secure. Need to switch to switch to one of these maybe? | |
# | |
# * https://github.com/marketplace/actions/workflow-dispatch | |
# * https://github.com/marketplace/actions/trigger-workflow-and-wait | |
# | |
# Deploy to star.sandbox.star.vote (argocd Kubernetes) | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: 'Equal-Vote/argocd' | |
token: ${{ secrets.GH_PAT }} | |
- name: Update argocd repo | |
run: | | |
yq -i ".image.tag = \"sha-${GITHUB_SHA::7}\"" applications/star-server/values.yaml | |
git config user.name github-actions | |
git config user.email [email protected] | |
git commit -am "Automatically updating star-server image." | |
git push |