Skip to content

manual_history_tag_docker_image_making #2

manual_history_tag_docker_image_making

manual_history_tag_docker_image_making #2

name: manual_history_tag_docker_image_making
on:
workflow_dispatch:
jobs:
build_images_by_tags:
runs-on: ubuntu-latest
steps:
- name: Checkout the codebase
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: install jq
run: sudo apt-get install jq
- name: Extract all existing tags and sha's for the repo using gh api and build containers
env:
GH-TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch --unshallow
export TAGS=$(curl -s https://api.github.com/repos/vlizBE/vocabserver-frontend/tags | jq -c '[.[] | {tag_name: .name, sha: .commit.sha}]')
echo $TAGS
# loop over $TAGS and echo the tag and the sha
for row in $(echo "${TAGS}" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
echo $(_jq '.tag_name')
echo $(_jq '.sha')
# checkout container at the sha
git checkout $(_jq '.sha')
export REG_NS="ghcr.io/vlizbe/vocabserver-frontend" # sets the public scope for these, no uppercases are allowed
TAG_NAME=$(_jq '.tag_name') # this is the tag name of the release
echo "Building $REG_NS:$TAG_NAME"
docker build -t $REG_NS:$TAG_NAME -f Dockerfile . || {
echo "Error building the Docker image $REG_NS:$TAG_NAME"
continue
}
docker push $REG_NS:$TAG_NAME
done
done