Skip to content

Promote

Promote #18

Workflow file for this run

name: Update images in Harbor
on:
schedule:
- cron: '0 5 * * 0' # Weekly on Sundays at 05:00
workflow_dispatch:
env:
IMAGE_NAME: teleservices/bookworm
DEBIAN_VERSION: bookworm
jobs:
staging:
runs-on:
group: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Harbor registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.HARBOR_URL }}
username: ${{ secrets.TELESERVICES_HARBOR_USERNAME }}
password: ${{ secrets.TELESERVICES_HARBOR_PASSWORD }}
- name: Build push image to registry
uses: docker/[email protected]
with:
context: teleservices
file: teleservices/Dockerfile
tags: |

Check failure on line 32 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / Update images in Harbor

Invalid workflow file

The workflow is not valid. .github/workflows/publish.yml (Line: 32, Col: 17): Unexpected symbol: '$GITHUB_RUN_NUMBER'. Located at position 5 within expression: env.$GITHUB_RUN_NUMBER .github/workflows/publish.yml (Line: 46, Col: 17): Unexpected symbol: '$GITHUB_RUN_NUMBER'. Located at position 5 within expression: env.$GITHUB_RUN_NUMBER
${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}:staging
${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}:staging-${{ env.$GITHUB_RUN_NUMBER }}
platforms: linux/amd64
pull: true
push: true
target: prod-image
build-args: |
DEBIAN_VERSION=$DEBIAN_VERSION
- name: Build push test image to registry
uses: docker/[email protected]
with:
context: teleservices
file: teleservices/Dockerfile
tags: |
${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}-test:staging
${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}-test:staging-${{ env.$GITHUB_RUN_NUMBER }}
platforms: linux/amd64
pull: true
push: true
target: dev-image
build-args: |
DEBIAN_VERSION=$DEBIAN_VERSION
- name: Install curl
run: sudo apt-get update && sudo apt-get install -y curl
- name: Restart staging instance
run: |
curl -k --fail --show-error --header "X-Rundeck-Auth-Token:${{ secrets.TELESERVICES_RUNDECK_TOKEN }}" -d "argString=-name staging" -d "filter=name ts001.staging.imio.be" ${{ secrets.RUNDECK_URL }}/api/18/job/94b605f2-ad32-4f9f-977e-37342f6b7d32/run/
- name : Send notification on Mattermost
run: |
JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
MESSAGE="docker staging image has been updated on registry and the staging instance has been restarted. [Click here to see job on GitHub]($JOB_URL)"
curl -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE\"}" ${{ secrets.TELESERVICES_MATTERMOST_WEBHOOK_URL }}
production:
needs: [staging]
environment:
name: production
timeout-minutes: 2880
runs-on:
group: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Harbor registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.HARBOR_URL }}
username: ${{ secrets.TELESERVICES_HARBOR_USERNAME }}
password: ${{ secrets.TELESERVICES_HARBOR_PASSWORD }}
- name: Tag prod images
run: |
docker tag ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}:staging ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}:latest
docker tag ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}:latest ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}:latest-${{ env.$GITHUB_RUN_NUMBER }}
docker tag ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}-test:staging ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}-test:latest
docker tag ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}-test:latest ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}-test:latest-${{ env.$GITHUB_RUN_NUMBER }}
- name: Push images to registry
run: |
docker push ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}:latest-${{ env.$GITHUB_RUN_NUMBER }}
docker push ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}-test:latest
docker push ${{ secrets.HARBOR_URL }}/${{ env.IMAGE_NAME }}-test:latest-${{ env.$GITHUB_RUN_NUMBER }}
- name: Install curl
run: sudo apt-get update && sudo apt-get install -y curl
- name: Schedule restart of all prod instances
run: |
curl -k --fail -XPOST --show-error --header "X-Rundeck-Auth-Token:${{ secrets.TELESERVICES_RUNDECK_TOKEN }}" ${{ secrets.RUNDECK_URL }}/api/18/job/311af116-fedc-4e33-b2a7-99c8651f8e9b/run/
- name : Send notification on Mattermost
run: |
JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
MESSAGE="docker prod image has been updated on registry. [Click here to see job on GitHub]($JOB_URL) A reboot of all production instances has been scheduled for tomorrow at 1am. "
curl -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE\"}" ${{ secrets.TELESERVICES_MATTERMOST_WEBHOOK_URL }}