Add Build Action
All checks were successful
Build and Push Image / spfn-website (push) Successful in 54s
All checks were successful
Build and Push Image / spfn-website (push) Successful in 54s
This commit is contained in:
parent
0718b17c00
commit
19ca39cf20
2 changed files with 56 additions and 36 deletions
56
.forgejo/workflows/build.yml
Normal file
56
.forgejo/workflows/build.yml
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
name: Build and Push Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["**"]
|
||||
|
||||
env:
|
||||
DOCKER_TLS_CERTDIR: /certs
|
||||
IMAGE_TAG: ${{ github.sha }}
|
||||
SHORT_SHA: ${{ github.sha }}
|
||||
|
||||
jobs:
|
||||
spfn-website:
|
||||
runs-on: debian-trixie
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Cache Container Storage
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
/var/lib/containers/storage
|
||||
/run/containers/storage
|
||||
~/.local/share/containers/storage
|
||||
key: image-cache
|
||||
|
||||
- name: Login to Registry
|
||||
run: $RNEX_CONTAINER_PLATFORM login -u ${{ secrets.PACKAGE_USER }} -p ${{ secrets.PACKAGE_PWD }} git.spbr.net
|
||||
|
||||
- name: Set Short SHA
|
||||
run: echo "SHORT_SHA=${GITHUB_SHA::6}" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and Push
|
||||
env:
|
||||
CI_REGISTRY_IMAGE: git.spbr.net/spacebar/spfn-website
|
||||
CI_COMMIT_SHORT_SHA: ${{ env.SHORT_SHA }}
|
||||
run: |
|
||||
$RNEX_CONTAINER_PLATFORM login -u ${{ secrets.PACKAGE_USER }} -p ${{ secrets.PACKAGE_PWD }} git.spbr.net
|
||||
$RNEX_CONTAINER_PLATFORM build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
|
||||
$RNEX_CONTAINER_PLATFORM push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
|
||||
|
||||
- name: Push Retagged Latest
|
||||
if: github.ref == 'refs/heads/main'
|
||||
env:
|
||||
CI_REGISTRY_IMAGE: git.spbr.net/spacebar/spfn-website
|
||||
CI_COMMIT_SHORT_SHA: latest
|
||||
CI_COMMIT_PREVIOUS_SHA: ${{ env.SHORT_SHA }}
|
||||
run: |
|
||||
$RNEX_CONTAINER_PLATFORM login -u ${{ secrets.PACKAGE_USER }} -p ${{ secrets.PACKAGE_PWD }} git.spbr.net
|
||||
$RNEX_CONTAINER_PLATFORM pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_PREVIOUS_SHA"
|
||||
$RNEX_CONTAINER_PLATFORM tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_PREVIOUS_SHA" "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
|
||||
$RNEX_CONTAINER_PLATFORM push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
default:
|
||||
image: quay.io/podman/stable
|
||||
|
||||
stages:
|
||||
- build-and-push-image
|
||||
- push-retagged-branch
|
||||
- push-retagged-latest
|
||||
|
||||
build-and-push-image:
|
||||
stage: build-and-push-image
|
||||
script:
|
||||
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- podman build --no-cache -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
|
||||
- podman push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
|
||||
|
||||
push-retagged-branch:
|
||||
stage: push-retagged-branch
|
||||
script:
|
||||
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- podman pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
|
||||
- podman tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
|
||||
- podman push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "push"
|
||||
when: on_success
|
||||
|
||||
push-retagged-latest:
|
||||
stage: push-retagged-latest
|
||||
script:
|
||||
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- podman pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
|
||||
- podman tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:latest"
|
||||
- podman push "$CI_REGISTRY_IMAGE:latest"
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"
|
||||
when: on_success
|
||||
Loading…
Reference in a new issue