summaryrefslogtreecommitdiffstats
path: root/roles/wiki-publish/tasks/main.yml
blob: 960aa01f2daff4f314a5baf37ef8843f845480ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
- name: Set up SSH directory
  ansible.builtin.file:
    path: "/home/{{ emacsconf_publish_user }}/.ssh"
    state: directory
    mode: '0700'
- name: Install SSH key for EmacsConf wiki
  ansible.builtin.get_url:
    url: https://emacsconf.org/id_rsa_anon_git_emacsconf
    dest: "/home/{{ emacsconf_publish_user }}/.ssh/id_rsa_anon_git_emacsconf"
    mode: '0600'
    owner: "{{ emacsconf_publish_user }}"
- name: Set up packages
  become: yes
  when: emacs_package and emacs_package != "emacs"
  block:
    # This repository is currently not working
    # - name: Add snapshot repository
    #   ansible.builtin.apt_repository:
    #     repo: deb http://emacs.ganneff.de/ buster main
    - name: Remove old package
      ansible.builtin.apt:
        name: emacs
        state: absent
    - name: Install Emacs snapshot
      ansible.builtin.apt:
        name: "{{ emacs_package }}"
        state: present
- name: Set up Emacs configuration for non-interactive publishing
  become: true
  become_user: "{{ emacsconf_publish_user }}"
  template:
    src: emacsconf-config.el
    dest: "{{ emacs_config_dir }}/emacsconf-config.el"
- name: Check if Emacs base configuration already exists
  become: true
  become_user: "{{ emacsconf_publish_user }}"
  lineinfile:
    dest: "{{ emacs_config_dir }}/init.el"
    state: present
    regexp: "emacsconf-config"
    line: "(load-file \"emacsconf-config.el\")"
- name: Set up or update repositories
  become: false
  tags: publish
  block:
    - name: Check out wiki repository
      ansible.builtin.git:
        repo: git://git.emacsconf.org/emacsconf-wiki
        dest: "{{ emacsconf_edit_wiki_dir }}"
      register: wiki_clone
      failed_when:
        - wiki_clone.failed
        - not 'Local modifications exist in repository' in wiki_clone.msg
        - not 'Failed to checkout branch' in wiki_clone.msg
    - name: Check out emacsconf-el
      ansible.builtin.git:
        repo: git@git.emacsconf.org:pub/emacsconf-el
        dest: "{{ emacsconf_el_dir }}"
      register: elisp
      failed_when:
        - elisp.failed
        - not 'Local modifications exist in repository' in elisp.msg
        - not 'Failed to checkout branch' in elisp.msg
    - name: Check out emacsconf-2022-private
      ansible.builtin.git:
        repo: git@git.emacsconf.org:emacsconf-2022-private
        dest: "{{ emacsconf_private_dir }}"
      register: private
      failed_when:
        - private.failed
        - not 'Local modifications exist in repository' in private.msg
        - not 'Failed to checkout branch' in private.msg
- name: Publish
  tags: publish
  block:
    - name: Publish the schedule
      command: emacs -l "{{ emacsconf_config_dir }}/emacsconf-config.el" --batch --exec '(emacsconf-generate-main-schedule)'
      when: (force_publish|d(false)) or ((private.changed or elisp.changed) and slug is not defined)
    - name: Update a specific talk's nav page
      tags: publish-talk
      command: emacs -l "{{ emacsconf_config_dir }}/emacsconf-config.el" --batch --exec '(emacsconf-with-talk-heading "{{ slug }}" (emacsconf-update-talk))'
      when: slug is defined
    - name: Commit the wiki and push
      shell: cd {{ emacsconf_edit_wiki_dir }}; git commit -m 'Update from ansible' -a; git push