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