Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: utilise correct docker credentials #634

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 78 additions & 79 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,83 @@
name: Release

on:
release:
types: [published]
release:
types: [published]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Docker registry auth
run: echo "${{ secrets.DOCKER_HUB_TOKEN_NC }}" | docker login --username namecheaprnd --password-stdin

- name: Calculate tags
id: tags
run: |
function isSemver() {
echo "${1}" | grep -Eq '^refs/tags/v?([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z]+(\.[0-9]+)?)?$'
}

echo $GITHUB_REF
if ! isSemver "${GITHUB_REF}"; then
echo "Invalid tag name format. Use semver style. Ex: v1.2.3"
exit 1
fi

DOCKER_TAGS=$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g" | sed -E "s/v?([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z]+(\.[0-9]+)?)?/\1.\2.\3\4 \1.\2\4 \1\4/g")

echo "Tags that will be used: $DOCKER_TAGS"
echo ::set-output name=docker_tags::$DOCKER_TAGS
echo ::set-output name=tag::$(echo $GITHUB_REF | cut -d / -f 3)

- name: Install regctl
run: |
curl -L https://github.com/regclient/regclient/releases/download/v0.3.10/regctl-linux-amd64 > ./regctl
chmod 755 ./regctl

- name: Push images
run: |
TAGS="${{ steps.tags.outputs.docker_tags }}"

for i in ${TAGS//,/ }
do
./regctl image copy namecheap/ilc:${GITHUB_SHA:0:7} namecheap/ilc:$i
./regctl image copy namecheap/ilc_registry:${GITHUB_SHA:0:7} namecheap/ilc_registry:$i
done

- name: Get release description
id: get_release
uses: octokit/[email protected]
with:
route: GET /repos/:repository/releases/tags/:tag_name
repository: ${{ github.repository }}
tag_name: ${{ steps.tags.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Parse release info
id: parse_release
uses: gr2m/[email protected]
with:
json: ${{ steps.get_release.outputs.data }}
id: "id"
body: "body"

- name: Update release description
uses: octokit/[email protected]
with:
route: PATCH /repos/:repository/releases/:release_id
repository: ${{ github.repository }}
release_id: ${{ steps.parse_release.outputs.id }}
body: |
|
${{ steps.parse_release.outputs.body }}

**Docker images:**
- [namecheap/ilc](https://hub.docker.com/r/namecheap/ilc): `${{ steps.tags.outputs.docker_tags }}`
- [namecheap/ilc_registry](https://hub.docker.com/r/namecheap/ilc_registry): `${{ steps.tags.outputs.docker_tags }}`
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Docker registry auth
run: echo "${{ secrets.DOCKER_HUB_BROTHERS_TOKEN }}" | docker login --username brothers --password-stdin

- name: Calculate tags
id: tags
run: |
function isSemver() {
echo "${1}" | grep -Eq '^refs/tags/v?([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z]+(\.[0-9]+)?)?$'
}

echo $GITHUB_REF
if ! isSemver "${GITHUB_REF}"; then
echo "Invalid tag name format. Use semver style. Ex: v1.2.3"
exit 1
fi

DOCKER_TAGS=$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g" | sed -E "s/v?([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z]+(\.[0-9]+)?)?/\1.\2.\3\4 \1.\2\4 \1\4/g")

echo "Tags that will be used: $DOCKER_TAGS"
echo ::set-output name=docker_tags::$DOCKER_TAGS
echo ::set-output name=tag::$(echo $GITHUB_REF | cut -d / -f 3)

- name: Install regctl
run: |
curl -L https://github.com/regclient/regclient/releases/download/v0.3.10/regctl-linux-amd64 > ./regctl
chmod 755 ./regctl

- name: Push images
run: |
TAGS="${{ steps.tags.outputs.docker_tags }}"

for i in ${TAGS//,/ }
do
./regctl image copy namecheap/ilc:${GITHUB_SHA:0:7} namecheap/ilc:$i
./regctl image copy namecheap/ilc_registry:${GITHUB_SHA:0:7} namecheap/ilc_registry:$i
done

- name: Get release description
id: get_release
uses: octokit/[email protected]
with:
route: GET /repos/:repository/releases/tags/:tag_name
repository: ${{ github.repository }}
tag_name: ${{ steps.tags.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Parse release info
id: parse_release
uses: gr2m/[email protected]
with:
json: ${{ steps.get_release.outputs.data }}
id: 'id'
body: 'body'

- name: Update release description
uses: octokit/[email protected]
with:
route: PATCH /repos/:repository/releases/:release_id
repository: ${{ github.repository }}
release_id: ${{ steps.parse_release.outputs.id }}
body: |
|
${{ steps.parse_release.outputs.body }}

**Docker images:**
- [namecheap/ilc](https://hub.docker.com/r/namecheap/ilc): `${{ steps.tags.outputs.docker_tags }}`
- [namecheap/ilc_registry](https://hub.docker.com/r/namecheap/ilc_registry): `${{ steps.tags.outputs.docker_tags }}`
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading