changed github actions to better match other procjects

This commit is contained in:
Aaro Koivukangas
2025-10-06 16:07:09 +03:00
parent 333abd90e5
commit 1d4a1febeb
2 changed files with 27 additions and 32 deletions
+24 -29
View File
@@ -1,45 +1,40 @@
name: Build and deploy containers
# Pushes to main will build containers with staging env's and push them as staging images, whereas release goes to production.
on:
on:
release:
types: [published]
push:
branches:
- main
env:
IMAGE_NAME: ${{ github.event_name == 'release' && 'timetrials' || 'timetrials-staging' }}
jobs:
push_package:
if: ${{ github.event_name == 'release' || (github.event_name == 'push' && !contains(github.event.head_commit.message, '#no-deploy')) }}
build_todo_frontend:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Extract Docker image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: "${{ vars.DOCKER_USERNAME }}/{{ env.IMAGE_NAME }}"
# images: "${{ vars.DOCKER_USERNAME }}/${IMAGE_NAME}"
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
#
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# This changes all uppercase characters to lowercase.
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:timetrials"
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
+3 -3
View File
@@ -1,8 +1,8 @@
name: Deploy to fly.io and create version
on:
push:
branches:
- main
# push:
# branches:
# - main
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}