builds updates and image downloader updates
Build and Push Image / build-and-push (push) Successful in 1m12s

This commit is contained in:
2026-05-02 23:04:45 -07:00
parent 73d521f82d
commit 749fe95903
2 changed files with 26 additions and 56 deletions
+3 -37
View File
@@ -15,44 +15,10 @@ jobs:
registry: gitea.nelson-household.com # Replace with your Gitea domain registry: gitea.nelson-household.com # Replace with your Gitea domain
username: ${{ gitea.actor }} username: ${{ gitea.actor }}
password: ${{ secrets.RUNNER_TOKEN }} password: ${{ secrets.RUNNER_TOKEN }}
- name: Delete Old Images and Containers (Docker versions < 1.10) - name: Delete Old Images and Containers
run: | run: |
CONTAINERS=$(docker ps -aq '--filter=reference='$(echo gitea\.nelson-household\.com\/joseph\.nelson4456\/koillection-uploader\/koilcollection-uploader | grep -oE '[^/]+' | head -1) || true) docker rm $(docker ps -a -q -f "name=koillection-uploader")
IMAGES=$(docker images -q '--filter=reference='$(echo gitea\.nelson-household\.com\/joseph\.nelson4456\/koillection-uploader\/koilcollection-uploader | grep -oE '[^/]+' | head -1) || true) docker rmi $(docker images --format "{{.Repository}}:{{.Tag}}" | grep "koillection-uploader")
if [ ! -z "$CONTAINERS" ]; then
echo "Deleting Containers:"
docker rm $CONTAINERS
fi
if [ ! -z "$IMAGES" ]; then
echo "Deleting Images:"
docker rmi $IMAGES
fi
- name: Delete Old Images and Containers (Docker version >= 1.10)
if: | docker version --format '{{ .Server.Version }}' | grep -q '1.10' || true; then
run: |
CONTAINERS=$(docker ps -aq --filter reference=gitea\.nelson-household\.com\/joseph\.nelson4456\/koillection-uploader\/koilcollection-uploader || true)
IMAGES=$(docker images -q --filter reference=gitea\.nelson-household\.com\/joseph\.nelson4456\/koillection-uploader\/koilcollection-uploader || true)
if [ ! -z "$CONTAINERS" ]; then
echo "Deleting Containers:"
docker rm $CONTAINERS
fi
if [ ! -z "$IMAGES" ]; then
echo "Deleting Images:"
docker rmi $IMAGES
fi
else
run: |
CONTAINERS=$(docker ps -aq '--filter=reference='$(echo gitea\.nelson-household\.com\/joseph\.nelson4456\/koillection-uploader\/koilcollection-uploader | grep -oE '[^/]+' | head -1) || true)
IMAGES=$(docker images -q '--filter=reference='$(echo gitea\.nelson-household\.com\/joseph\.nelson4456\/koillection-uploader\/koilcollection-uploader | grep -oE '[^/]+' | head -1) || true)
if [ ! -z "$CONTAINERS" ]; then
echo "Deleting Containers:"
docker rm $CONTAINERS
fi
if [ ! -z "$IMAGES" ]; then
echo "Deleting Images:"
docker rmi $IMAGES
fi
endif
- name: Build and Push Image - name: Build and Push Image
run: | run: |
docker build -t gitea.nelson-household.com/joseph.nelson4456/koillection-uploader/koilcollection-uploader:${{ github.sha }} . docker build -t gitea.nelson-household.com/joseph.nelson4456/koillection-uploader/koilcollection-uploader:${{ github.sha }} .
+19 -15
View File
@@ -1,4 +1,6 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path');
const csvParser = require('csv-parser');
// Define the target directory for saving images // Define the target directory for saving images
let imageDir = './master-set-images/perfect-order'; let imageDir = './master-set-images/perfect-order';
@@ -6,25 +8,27 @@ if (!fs.existsSync(imageDir)) {
fs.mkdirSync(imageDir); fs.mkdirSync(imageDir);
} }
// Read the CSV file line by line // Read the CSV file using csv-parser
const stream = fs.createReadStream('./csv/ME03PerfectOrderProductsAndPrices.csv'); const stream = fs.createReadStream('./csv/ME03PerfectOrderProductsAndPrices.csv')
let data = []; .pipe(csvParser());
stream.on('data', chunk => data.push(chunk)); let products = [];
stream.on('data', row => products.push(row));
stream.on('end', () => { stream.on('end', () => {
let rows = data.toString().split('\n').slice(1); // Loop through each product and download its image if the file doesn't exist
products.forEach(product => {
// Loop through each row (product) and download its image const imgUrl = product['imageUrl'];
rows.forEach(row => { const fileName = product['productId'] + '.jpg';
const columns = row.split(/[\t,]/).map(c => c.trim()); const filePath = path.join(imageDir, fileName);
fs.access(filePath, (err) => {
if (!!columns[3]) { // Image URL exists if (err) { // File doesn't exist
let imgUrl = columns[3]; // Change image resolution console.log('Downloading', imgUrl);
const fileName = columns[0]; // Get the file name (cleanName)
console.log(imgUrl);
fetch(imgUrl) fetch(imgUrl)
.then(res => res.arrayBuffer()) .then(res => res.arrayBuffer())
.then(buffer => fs.writeFileSync(`${imageDir}/${fileName}.jpg`, Buffer.from(buffer))) .then(buffer => fs.writeFileSync(filePath, Buffer.from(buffer)))
.catch(err => console.error(err)); .catch(err => console.error(err));
} else { // File exists
console.log('Skipping', fileName);
} }
}); });
}); });
});