Move from commit sha to tag for server
This commit is contained in:
@@ -10,25 +10,25 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
exists: ${{ steps.exists.outputs.exists }}
|
exists: ${{ steps.exists.outputs.exists }}
|
||||||
sha: ${{ steps.sha.outputs.sha }}
|
tag: ${{ steps.tag.outputs.tag }}
|
||||||
steps:
|
steps:
|
||||||
# Get latest timelimit-server commit SHA
|
# Get latest timelimit-server tag
|
||||||
- name: Get timelimit-server commit SHA
|
- name: Get timelimit-server tag
|
||||||
id: sha
|
id: tag
|
||||||
run: |
|
run: |
|
||||||
SHA=$(git ls-remote https://gitea.furb.it/${{ vars.SERVER_PATH }}.git refs/heads/${{ vars.SERVER_BRANCH }} | cut -f1)
|
LATEST_TAG=$(git ls-remote --tags --refs https://gitea.furb.it/${{ vars.SERVER_PATH }}.git | sort -t '/' -k 3 -V | tail -n 1 | cut -f2 | sed 's/refs\/tags\///')
|
||||||
echo "sha=$SHA" >> $GITEA_OUTPUT
|
echo "tag=$LATEST_TAG" >> $GITEA_OUTPUT
|
||||||
|
|
||||||
# Try to read timelimit-server SHA from latest image label
|
# Try to read timelimit-server tag from latest image label
|
||||||
- name: Check if image with timelimit-server SHA exists
|
- name: Check if image with timelimit-server tag exists
|
||||||
id: exists
|
id: exists
|
||||||
run: |
|
run: |
|
||||||
SHA="${{ steps.sha.outputs.sha }}"
|
TAG="${{ steps.tag.outputs.tag }}"
|
||||||
|
|
||||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
-u "${{ secrets.USERNAME }}:${{ secrets.ACCESS_TOKEN }}" \
|
-u "${{ secrets.USERNAME }}:${{ secrets.ACCESS_TOKEN }}" \
|
||||||
-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
|
-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
|
||||||
https://gitea.furb.it/v2/${{ vars.SERVER_IMAGE }}/manifests/$SHA)
|
https://gitea.furb.it/v2/${{ vars.SERVER_IMAGE }}/manifests/$TAG)
|
||||||
|
|
||||||
if [ "$STATUS" = "200" ]; then
|
if [ "$STATUS" = "200" ]; then
|
||||||
echo "exists=true" >> $GITEA_OUTPUT
|
echo "exists=true" >> $GITEA_OUTPUT
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: ${{ vars.SERVER_PATH }}.git
|
repository: ${{ vars.SERVER_PATH }}.git
|
||||||
ref: ${{ needs.check.outputs.sha }}
|
ref: ${{ needs.check.outputs.tag }}
|
||||||
token: ${{ secrets.ACCESS_TOKEN }}
|
token: ${{ secrets.ACCESS_TOKEN }}
|
||||||
|
|
||||||
# Login to registry (needed to inspect latest image)
|
# Login to registry (needed to inspect latest image)
|
||||||
@@ -57,18 +57,19 @@ jobs:
|
|||||||
-u "${{ secrets.USERNAME }}" \
|
-u "${{ secrets.USERNAME }}" \
|
||||||
--password-stdin
|
--password-stdin
|
||||||
|
|
||||||
# Build image with commit-SHA tag and label
|
# Build image with tag
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
-f Dockerfile \
|
-f Dockerfile \
|
||||||
--label timelimit-server.sha=${{ needs.check.outputs.sha }} \
|
--label timelimit-server.tag=${{ needs.check.outputs.tag }} \
|
||||||
-t gitea.furb.it/${{ vars.SERVER_IMAGE }}:${{ needs.check.outputs.sha }} \
|
-t gitea.furb.it/${{ vars.SERVER_IMAGE }}:${{ needs.check.outputs.tag }} \
|
||||||
-t gitea.furb.it/${{ vars.SERVER_IMAGE }}:latest \
|
-t gitea.furb.it/${{ vars.SERVER_IMAGE }}:latest \
|
||||||
.
|
.
|
||||||
|
|
||||||
# Push images
|
# Push images
|
||||||
- name: Push Docker images
|
- name: Push Docker images
|
||||||
run: |
|
run: |
|
||||||
docker push gitea.furb.it/${{ vars.SERVER_IMAGE }}:${{ needs.check.outputs.sha }}
|
docker push gitea.furb.it/${{ vars.SERVER_IMAGE }}:${{ needs.check.outputs.tag }}
|
||||||
docker push gitea.furb.it/${{ vars.SERVER_IMAGE }}:latest
|
docker push gitea.furb.it/${{ vars.SERVER_IMAGE }}:latest
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user