Skip to content

Commit 51e6912

Browse files
1.2.0: improvements, bug fixing and ci
* ci: publish.yml triggers on push/pr in master * fix: sha and deploy btn adopt the new GitHub UI * feature: support 2 deployable URLs homepage & commit details view * fix: display btn only appears in homepage and deployable URL. it also hides when not matching owner & repo from settings popup. * bump version to 1.2.0 * ci: publish only in master push
1 parent 935fef9 commit 51e6912

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: CI - Publish in Chrome Store
2-
on: repository_dispatch
2+
on:
3+
push:
4+
branches: [ master ]
35

46
jobs:
57
build:
@@ -30,5 +32,3 @@ jobs:
3032
client-id: ${{ secrets.CLIENT_ID }}
3133
client-secret: ${{ secrets.SECRET }}
3234
refresh-token: ${{ secrets.REFRESH_TOKEN }}
33-
# optionally specify the visibility of the addon
34-
# publishTarget: default

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "easy-deploy",
33
"description": "Easy Deploy is a chrome extension that allows you to manually trigger a GitHub Action ",
4-
"version": "1.1.0",
4+
"version": "1.2.0",
55
"author": {
66
"email": "[email protected]",
77
"name": "Alejandro Lora"

src/app/shared/helpers/dom.helper.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Settings } from '../interfaces/settings.interface';
2+
import { Environment } from '../interfaces/environment.interface';
23

34
import { URLHelper } from './url.helper';
45
import { GitHubHelper } from './github.helper';
@@ -25,7 +26,7 @@ export class DomHelper {
2526

2627
this.subscribeToStorageChanges();
2728

28-
if (this.settings && this.isMatchingOwnerAndRepo()) {
29+
if (this.settings && this.isMatchingOwnerAndRepo() && URLHelper.isDeployableURL()) {
2930
this.showDisplayBtn();
3031
this.refreshEnvironmentButtonList();
3132
}
@@ -36,9 +37,9 @@ export class DomHelper {
3637
return document.querySelector('#branch-select-menu') as HTMLElement;
3738
}
3839

39-
private getSHARef() {
40+
private getSHARef(environment: Environment) {
4041
if (URLHelper.isDeployableURL() && this.getContainer()) {
41-
const anchor: HTMLAnchorElement = document.querySelector('.commit-tease-sha');
42+
const anchor: HTMLAnchorElement = document.querySelector(`.Box-header a[href^="/${environment.repoOwner}/${environment.repoName}/commit/"]`);
4243
return anchor.href.split('/commit/')[1];
4344
}
4445
}
@@ -84,7 +85,7 @@ export class DomHelper {
8485

8586
private createDropDownBtn() {
8687
const dropDownBtn = document.createElement('summary');
87-
dropDownBtn.classList.add('select-menu-button', 'btn', 'btn-sm', 'btn-primary', 'ml-2');
88+
dropDownBtn.classList.add('select-menu-button', 'btn', 'btn-primary', 'ml-2');
8889
dropDownBtn.innerHTML = '<span> Deploy </span>';
8990
return dropDownBtn;
9091
}
@@ -124,7 +125,7 @@ export class DomHelper {
124125

125126
private removeAllEnvironmentButtons() {
126127
if (this.environmentsButtonList) {
127-
this.showDisplayBtn();
128+
this.hideDisplayBtn();
128129
while (this.environmentsButtonList.firstChild) {
129130
this.environmentsButtonList.removeChild(this.environmentsButtonList.lastChild);
130131
}
@@ -133,7 +134,7 @@ export class DomHelper {
133134

134135
private refreshEnvironmentButtonList() {
135136
this.removeAllEnvironmentButtons();
136-
if (!this.settings.environments.length || !this.isMatchingOwnerAndRepo()) {
137+
if (!this.settings.environments.length || !this.isMatchingOwnerAndRepo() || !URLHelper.isDeployableURL()) {
137138
return;
138139
}
139140
for (const environment of this.settings.environments) {
@@ -174,7 +175,7 @@ export class DomHelper {
174175
this.closeDropDown();
175176

176177
const environment = this.settings.environments.find((env) => env.id === button.id);
177-
const sha = this.getSHARef();
178+
const sha = this.getSHARef(environment);
178179

179180
const gitHubHelper = new GitHubHelper(this.settings.token, environment.repoOwner, environment.repoName);
180181
await gitHubHelper.actionDispatch(sha, environment.event);

src/app/shared/helpers/url.helper.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ export class URLHelper {
88
}
99

1010
static isDeployableURL() {
11-
return location.pathname
12-
.split(`/${this.getOwner()}/${this.getRepositoryName()}/tree/`)
13-
.filter((e) => e).length === 1;
11+
const urlTreeSplit = location.pathname.split(`/tree/`);
12+
const isTreeCommitURL =
13+
urlTreeSplit[0] === `/${this.getOwner()}/${this.getRepositoryName()}` &&
14+
urlTreeSplit[1]?.indexOf('/') === -1;
15+
const isHomePageURL = location.pathname.replace(/\/+$/, '') === `/${this.getOwner()}/${this.getRepositoryName()}`;
16+
17+
return isTreeCommitURL || isHomePageURL;
1418
}
1519
}

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Easy Deploy",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Allows you to manually trigger a GitHub Action",
55
"manifest_version": 2,
66
"icons": {

0 commit comments

Comments
 (0)