Closed wenboown closed 4 months ago
I want to separate production (stable) and development (latest). can you help me?
Currently, I have a workflow file that refers:
which points to the latest tag release we made above.
then the action.yml has: using: 'docker' image: 'docker://ghcr.io/seineai/seine_sailor:latest' # change the latest to v1, v2... to separate dev and release
Which points to a docker image that we build and push when creating the latest release.
But I think the ideal setup should be: when I make a push or manually trigger a build workflow. it updates the latest docker image for the development. so an action.yml points to the "latest" or "dev" docker image. when I am ready for a release. It creates a new release and updates a docker image with "stable" or "prod" tag, and have the action.yml points to it. Then I can instruct my users to use a workflow yml points to uses: SeineAI/SeineSailor@stable and my development team use a workflow yml points to uses: SeineAI/SeineSailor@latest
is this possible?
ChatGPT-4o said:
Yes, it is possible to set up separate workflows for development (latest) and production (stable) Docker images, and to have your GitHub Actions workflows use the appropriate version for each environment. Below is a detailed plan on how to achieve this.
Create a workflow that builds and pushes the Docker image with the latest
tag whenever there's a push to the main
branch or a manual trigger.
.github/workflows/update-latest.yml
name: Update Latest Docker Image
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
run: |
docker build -t ghcr.io/seineai/seine_sailor:latest .
docker push ghcr.io/seineai/seine_sailor:latest
Create a workflow that builds and pushes the Docker image with a versioned tag and updates the stable
tag. This workflow will be triggered manually when you're ready to release.
.github/workflows/update-stable.yml
name: Update Stable Docker Image
on:
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push versioned Docker image
run: |
VERSION=$(date +%Y%m%d%H%M%S) # or use any versioning scheme you prefer
docker build -t ghcr.io/seineai/seine_sailor:$VERSION .
docker push ghcr.io/seineai/seine_sailor:$VERSION
- name: Update stable tag
run: |
docker tag ghcr.io/seineai/seine_sailor:$VERSION ghcr.io/seineai/seine_sailor:stable
docker push ghcr.io/seineai/seine_sailor:stable
action.yml
to Use Appropriate Docker TagsUpdate your action.yml
to point to either latest
or stable
based on the intended usage.
action.yml
name: 'SeineSailor'
description: 'Your action description'
author: 'SeineAI'
runs:
using: 'docker'
image: 'docker://ghcr.io/seineai/seine_sailor:${{ inputs.tag }}'
inputs:
tag:
description: 'Tag of the Docker image to use'
required: true
default: 'stable' # or 'latest' for development
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Use SeineSailor Latest
uses: SeineAI/SeineSailor@latest
with:
tag: latest
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Use SeineSailor Stable
uses: SeineAI/SeineSailor@stable
with:
tag: stable
latest
Docker image on push to main
or manual trigger.stable
tag.action.yml
uses an input to select between latest
and stable
Docker images.latest
) and production (stable
). This setup ensures a clear separation between development and production environments and allows for easy updates and deployment.
fixed in 1bfef74
This is hallucination:
runs:
using: 'docker'
image: 'docker://ghcr.io/seineai/seine_sailor:${{ inputs.tag }}'
After research, we confirmed that the github action runner cannot access inputs.tag
. We will encounter errors like:
Error: SeineAI/SeineSailor/main/action.yml (Line: 211, Col: 10): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.tag Error: Failed to load SeineAI/SeineSailor/main/action.yml
We also tried things like:
image: 'docker://ghcr.io/seineai/seine_sailor:${{ $INPUT_TAG }}'
or
image: 'docker://ghcr.io/seineai/seine_sailor:${{ github.ref == 'refs/heads/main' && 'stable' || 'latest' }}'
They don't work either.
runs can be found at: https://github.com/SeineAI/SeineSailor/actions/runs/9131996292/job/25118846134
Final solution is in https://github.com/SeineAI/SeineSailor/pull/18
We added https://github.com/SeineAI/SeineSailor/blob/5bbf1d04d3320735da04a94b61c1dc865508b968/.github/workflows/release.yml#L42
to
release-drafter
. It correctly tagged one release aslatest
. But afterwards it cannot create any new releases.https://github.com/SeineAI/SeineSailor/actions/runs/9104260759/job/25027772624#step:2:229