Skip to content

Volunteer list

Volunteer list #31

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/[email protected]
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/[email protected]
- name: Docker Login
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push Docker images
uses: docker/[email protected]
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
- name: Checkout
uses: actions/[email protected]
with:
repository: 'Equal-Vote/star-server-infra'
token: ${{ secrets.GH_PAT }}
- name: Update star-server-infra repo variables.tf with new container tag
run: |
sed -i "s#\"ghcr.io/${{ env.REPO }}:.*#\"ghcr.io/${{ env.REPO }}:sha-${GITHUB_SHA::7}\"#" variables.tf
git config user.name github-actions
git config user.email [email protected]
git commit -am "Automatically updating star-server image."
git push