nix-doom-emacs-unstraightened/.github/workflows/push-flake-update.yml
Marien Zwart 0c55f6064f
CI: try to make push of flake-update to main work
It currently fails with

```
 ! [rejected]        HEAD -> main (fetch first)
error: failed to push some refs to 'https://github.com/marienz/nix-doom-emacs-unstraightened'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for
details.
```

Our local checkout is shallow. Assume we can fix this by fetching just
the parent of the commit we want to push, which should be the commit
origin/main points at.
2024-06-22 22:29:35 +10:00

44 lines
1.6 KiB
YAML

# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Push flake-update
on:
workflow_dispatch:
workflow_call:
jobs:
commit:
runs-on: ubuntu-latest
permissions:
contents: "write"
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: flake-update
# Fetch the parent of the commit we want to push too:
# that should be the current ref of `main`, which we need
# for push to succeed (without forcing).
fetch-depth: 2
- name: Push changes
run: git push origin HEAD:main
# `git push` only works because branch protection is not enabled.
#
# Currently branch protection is not effective anyway, since the only
# contributor (marienz) has admin permissions, and applying branch
# protection to administrators seems to be an "organization" feature.
#
# The supported path seems to be "create a PR and use the API to merge
# it", but that's more work to implement: revisit later if needed.