Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMSP-726] switch to gha #116

Merged
merged 71 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
e618fe7
add a test workflow
jazzsequence Jan 9, 2024
d00680d
also run on release
jazzsequence Jan 9, 2024
35969e1
add git config
jazzsequence Jan 9, 2024
3ef4cd8
add the docker-updatinator image
jazzsequence Jan 9, 2024
ea7fa5e
use v2 checkout(?)
jazzsequence Jan 9, 2024
49830c7
add write permissions to the bot
jazzsequence Jan 10, 2024
6af6458
run as root
jazzsequence Jan 10, 2024
9351ede
add an ssh key to authenticate for whoami test
jazzsequence Jan 10, 2024
4ce6e8b
login to github with the right token
jazzsequence Jan 10, 2024
4f36935
remove quay container and just use gh
jazzsequence Jan 10, 2024
4b3a89c
set auth token perms to read all
jazzsequence Jan 10, 2024
ce5b3a4
remove permissions entirely
jazzsequence Jan 10, 2024
b9f34ee
re-add write permissions
jazzsequence Jan 10, 2024
b1f8cd7
move the git config higher and output the status to see if we can fig…
jazzsequence Jan 10, 2024
518f804
export the gh token
jazzsequence Jan 10, 2024
5ab9af1
unset the existing GITHUB_TOKEN before using ours
jazzsequence Jan 10, 2024
f0a0795
make it a separate step
jazzsequence Jan 10, 2024
25e9a87
also unset and export GH_TOKEN
jazzsequence Jan 10, 2024
c379e14
use the actual token rather than variable we exported
jazzsequence Jan 10, 2024
30e023f
allow ssh for debugging
jazzsequence Jan 10, 2024
f4a3dbd
move tmate to after failing test
jazzsequence Jan 10, 2024
8746cb2
allow other users to ssh in
jazzsequence Jan 10, 2024
34d9898
maybe switching to false will actually let us log in?
jazzsequence Jan 10, 2024
2a214b7
try not running whoami
jazzsequence Jan 10, 2024
6648552
I guess put stuff in here since we committed it to vc
jazzsequence Jan 10, 2024
ca600d6
add unset to the regular script
jazzsequence Jan 10, 2024
778291a
remove typo
jazzsequence Jan 10, 2024
e4f5541
remove --with-token
jazzsequence Jan 10, 2024
490a02a
set tokens as env variables in the job
jazzsequence Jan 10, 2024
495fe38
remove tmate
jazzsequence Jan 10, 2024
895c323
add tokens to test steps, too
jazzsequence Jan 10, 2024
837efa1
unset tokens again
jazzsequence Jan 10, 2024
52f9b1b
maybe don't need to auth?
jazzsequence Jan 10, 2024
21c69b6
okay, let's whoami with this token
jazzsequence Jan 10, 2024
4565625
use php 7.4
jazzsequence Jan 10, 2024
6fdcc9a
install php 7.4 earlier
jazzsequence Jan 10, 2024
c3f3344
add mariadb for wp tests
jazzsequence Jan 10, 2024
14092ca
add custom db name
jazzsequence Jan 10, 2024
e7d0333
define empty password for root user
jazzsequence Jan 10, 2024
176c60a
use the updatinator container
jazzsequence Jan 10, 2024
e7b85c1
grant write permissiosn
jazzsequence Jan 10, 2024
2067099
use container as root
jazzsequence Jan 10, 2024
6698fc2
pass env variables into the test step
jazzsequence Jan 10, 2024
94d64d4
install wp-cli
jazzsequence Jan 10, 2024
9a090fa
remove the root password since it's not part of the fixture
jazzsequence Jan 10, 2024
1162edb
test the database
jazzsequence Jan 10, 2024
a6efc26
set root password to empty
jazzsequence Jan 10, 2024
75006c2
try connecting with root password
jazzsequence Jan 10, 2024
9330efb
set password to empty string
jazzsequence Jan 10, 2024
221618e
more database setup
jazzsequence Jan 10, 2024
d87bb7b
change how we set the password
jazzsequence Jan 10, 2024
ee65a9d
don't use PASSWORD()
jazzsequence Jan 10, 2024
885ab34
remove the password for the blank password test
jazzsequence Jan 10, 2024
0ad2c15
don't create the database
jazzsequence Jan 10, 2024
b2c7740
remove test workflow since it's converted to gha
jazzsequence Jan 11, 2024
1b70853
rename deploy to publish
jazzsequence Jan 11, 2024
70840a3
set test to run on tag creation rather than release creation
jazzsequence Jan 11, 2024
f2f2b0a
send dispatch so releases are chained from tests
jazzsequence Jan 11, 2024
4a6e65d
change the trigger to repository_dispatch
jazzsequence Jan 11, 2024
1d38e2e
change the job name to publish
jazzsequence Jan 11, 2024
556652e
setup php
jazzsequence Jan 11, 2024
2d321ae
get the tag name that was just created
jazzsequence Jan 11, 2024
8a4dd25
publish the release
jazzsequence Jan 11, 2024
073dc12
build the update-tool.phar
jazzsequence Jan 11, 2024
ceeec7e
upload the phar to the release
jazzsequence Jan 11, 2024
8faf239
delete circle workflow
jazzsequence Jan 11, 2024
9c10528
Use GitHub test badge
jazzsequence Jan 11, 2024
720a3f0
update notes
jazzsequence Jan 11, 2024
2ef12aa
use checkout@v3
jazzsequence Jan 11, 2024
4939fef
use a non-deprecated release action
jazzsequence Jan 11, 2024
a6d63cc
one does not simply create a new tag
jazzsequence Jan 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions .circleci/config.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy
on:
repository_dispatch:
types: [tests-passed]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Get tag name
id: tag_name
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Publish Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_name.outputs.tag }}
release_name: ${{ steps.tag_name.outputs.tag }}
body: Version ${{ steps.tag_name.outputs.tag }}
draft: false
prerelease: false
- name: Build phar
run: |
composer install
composer phar:build
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./update-tool.phar
asset_name: update-tool.phar
asset_content_type: application/octet-stream
76 changes: 76 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Test
on:
pull_request:
push:
tags:
- '*'

permissions: write-all

jobs:
test:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.5
steps:
- uses: actions/checkout@v3
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- name: Setup MySQL
run: |
sudo systemctl start mysql
mysqladmin -h 127.0.0.1 -u root -proot status
echo "Setting the root password to empty"
mysql -h 127.0.0.1 -u root -proot -e "USE mysql; UPDATE user SET authentication_string='' WHERE User='root'; FLUSH PRIVILEGES;"
echo "Testing blank password"
mysqladmin -h 127.0.0.1 -u root status
- name: Install Composer Dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Install SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PANTHEON_UPSTREAM_SSH_KEY }}
- name: Unset GitHub Tokens
shell: bash
run: |
unset GITHUB_TOKEN
unset GH_TOKEN
- name: Run Update Tool Whoami
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.PANTHEON_UPSTREAM_AUTH_TOKEN }}
GH_TOKEN: ${{ secrets.PANTHEON_UPSTREAM_AUTH_TOKEN }}
run: |
echo "Set git config"
git config --global user.email "[email protected]"
git config --global user.name "Pantheon Automation"
echo "Login with gh auth"
# gh auth login
gh auth status
./update-tool whoami
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --info
- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.PANTHEON_UPSTREAM_AUTH_TOKEN }}
GH_TOKEN: ${{ secrets.PANTHEON_UPSTREAM_AUTH_TOKEN }}
DB_USER: root
DB_NAME: updatinate-wp-db
run: composer test
send-dispatch:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Send Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.PANTHEON_UPSTREAM_AUTH_TOKEN }}
repository: pantheon-systems/update-tool
event-type: tests-passed
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Fast and smart. Update Tool checks for available software updates and creates pull requests.

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/pantheon-systems/update-tool/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/pantheon-systems/update-tool/tree/master)
[![Test](https://github.com/pantheon-systems/update-tool/actions/workflows/test.yml/badge.svg)](https://github.com/pantheon-systems/update-tool/actions/workflows/test.yml)
[![Actively Maintained](https://img.shields.io/badge/Pantheon-Actively_Maintained-yellow?logo=pantheon&color=FFDC28)](https://pantheon.io/docs/oss-support-levels#actively-maintained-support)
[![License](https://img.shields.io/badge/license-MIT-408677.svg)](LICENSE)

Expand All @@ -29,7 +29,7 @@ The authentication credentials you will need can be found in the production Vaul

*Production:* In production, this tool uses the credentials defined in the [pantheon-systems/updatinator](https://github.com/pantheon-systems/updatinator) project.

*Testing:* CircleCI needs a GitHub token for a service account that has access to the projects in the [test-configurations.yml](tests/fixtures/home/test-configuration.yml) fixtures file. Currently, the github user pantheon-ci-bot is being used. Access it via:
*Testing:* GitHub Actions needs a GitHub token for a service account that has access to the projects in the [test-configurations.yml](tests/fixtures/home/test-configuration.yml) fixtures file. Currently, the GitHub user `pantheon-ci-bot` is being used. Access it via:

```
pvault production read secret/github/access-tokens/pantheon-ci-bot
Expand Down Expand Up @@ -57,10 +57,10 @@ The test suite may be run locally by way of some simple composer scripts:

### Releasing

To release a new version of the Update Tool, run:
To release a new version of the Update Tool, simply create a new tag at the appropriate version. This will trigger the tests to run again. Assuming the tests pass, that send a release dispatch that triggers another GitHub Action to publish the release and upload the `update-tool.phar` to the release.
jazzsequence marked this conversation as resolved.
Show resolved Hide resolved

- `composer release`
Rebuild [pantheon-systems/docker-updatinator](https://github.com/pantheon-systems/docker-updatinator) to deploy a new version of the tool to the automation processes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebuild where/how? Rebuild in github? Rebuild in Quay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so. This was copy/pasta from the original notes.


This will release a stable version of whatever is indicated in the VERSION file. e.g. if VERSION contains `1.0.3-dev`, then version `1.0.3` will be tagged and released, and the VERSION file will be updated to `1.0.4-dev`. To release version `1.1.0` instead, manually edit the VERSION file to `1.1.0-dev` and then run `composer release`.
Alternately, you can use the Composer script `composer release`.

The update-tool.phar file will be uploaded to GitHub on every release. Rebuild [pantheon-systems/docker-updatinator](https://github.com/pantheon-systems/docker-updatinator) to deploy a new version of the tool to the automation processes.
This will release a stable version of whatever is indicated in the VERSION file. e.g. if VERSION contains `1.0.3-dev`, then version `1.0.3` will be tagged and released, and the VERSION file will be updated to `1.0.4-dev`. To release version `1.1.0` instead, manually edit the VERSION file to `1.1.0-dev` and then run `composer release`. This requires maintaining the `VERSION` file which historically has not been consistently updated, and simply creating the tag and allowing automation to handle the release is a more straightforward process.