I’m trying to get rollback working, it seems to work step wise but I’m unsure on how to change the “active” commit in Drone.
This is my .drone.yml section for the rollback:
--- kind: pipeline type: docker name: Rollback clone: disable: true trigger: event: - rollback target: - production steps: - name: clone repository image: alpine/git commands: - git clone https://github.com/<redacted>/mountain.git . - name: force push previous commit to environment image: alpine/git environment: GIT_REMOTE_URL: "ssh://dokku@<redacted>:22/mountain-prod" SSH_PRIVATE_KEY: from_secret: DOKKU_SSH_PRIVATE_KEY commands: - mkdir -p /root/.ssh - echo "$SSH_PRIVATE_KEY" | tr -d '\r' >/root/.ssh/id_ed25519 - chmod 600 /root/.ssh/id_ed25519 - chmod 700 /root/.ssh - ssh-keyscan -H -p 22 <redacted> >>/root/.ssh/known_hosts - eval $(ssh-agent -s) - ssh-add /root/.ssh/id_ed25519 - export PREVIOUS_COMMIT_SHA=$(git rev-parse HEAD^1) - git push --force "$GIT_REMOTE_URL" "$PREVIOUS_COMMIT_SHA:master"
So what I’m doing on rollback is getting the previous commit and force pushing that to my Dokku instance. It seems to work but the commit sha and message in Drone is the same commit as before.
Am I misunderstanding how this feature should be used or is there any information regarding this that I could read to handle this in a better way? I’ve spent the day hunting both in Discourse and on Google and haven’t found anything useful.
Any help appreciated! Thanks!
---- UPDATE —
Leaving this as is for anyone hitting this one in the future.
I was going about this the wrong way, really stupid when I realized it.
You select the commit you want to rollback to and then it’s just business as usual and $DRONE_COMMIT is of course available and I use that instead of this “hacky” way of retrieving the previous commit.
As always really fun in the end and a lesson learnt