@@ -68,20 +68,36 @@ const { execSync } = __webpack_require__(498)
6868let apt = core . getInput ( 'apt-get' ) . replace ( / [ ^ a - z _ \d . - ] + / gi, '' ) . trim ( ) . toLowerCase ( )
6969
7070const run = async ( ) => {
71- let needUpdate = true
7271 try {
7372 if ( apt !== '' ) {
74-
75- if ( apt . includes ( '_upgrade_' ) ) {
76- execSync ( 'sudo apt-get -qy update' )
73+
74+ const opts = '-o Acquire::Retries=3'
75+ let needUpdate = true
76+ let needUpgrade = true
77+
78+ if ( / \b _ u p d a t e _ \b / . test ( apt ) ) {
79+ execSync ( `sudo apt-get ${ opts } -qy update` )
80+ apt = apt . replace ( / \b _ u p d a t e _ \b / gi, '' ) . trim ( )
7781 needUpdate = false
78- execSync ( 'sudo apt-get -qy dist-upgrade' )
82+ }
83+
84+ if ( / \b _ d i s t - u p g r a d e _ \b / . test ( apt ) ) {
85+ if ( needUpdate ) { execSync ( 'sudo apt-get -qy update' ) }
86+ execSync ( `sudo apt-get ${ opts } -qy dist-upgrade` )
87+ needUpgrade = false
88+ apt = apt . replace ( / \b _ d i s t - u p g r a d e _ \b / gi, '' ) . trim ( )
89+ }
90+
91+ if ( / \b _ u p g r a d e _ \b / . test ( apt ) ) {
92+ if ( needUpgrade ) {
93+ if ( needUpdate ) { execSync ( `sudo apt-get ${ opts } -qy update` ) }
94+ execSync ( `sudo apt-get ${ opts } -qy upgrade` )
95+ }
7996 apt = apt . replace ( / \b _ u p g r a d e _ \b / gi, '' ) . trim ( )
8097 }
8198
8299 if ( apt !== '' ) {
83- if ( needUpdate ) { execSync ( 'sudo apt-get -qy update' ) }
84- execSync ( `sudo apt-get -qy --no-install-recommends install ${ apt } ` )
100+ execSync ( `sudo apt-get ${ opts } -qy --no-install-recommends install ${ apt } ` )
85101 }
86102 }
87103 } catch ( error ) {
@@ -1777,20 +1793,20 @@ let brew = core.getInput('brew').replace(/[^a-z_ \d.@-]+/gi, '').trim().toLowerC
17771793const run = async ( ) => {
17781794 try {
17791795 if ( brew !== '' ) {
1780- if ( brew . includes ( '_update_' ) ) {
1796+ let needUpdate = true
1797+
1798+ if ( / \b _ u p d a t e _ \b / . test ( brew ) ) {
17811799 execSync ( 'brew update' )
1800+ needUpdate = false
17821801 brew = brew . replace ( / \b _ u p d a t e _ \b / gi, '' ) . trim ( )
17831802 }
1784-
1785- if ( brew . includes ( '_upgrade_' ) ) {
1786- execSync ( 'brew update' )
1787- execSync ( 'brew upgrade' )
1803+
1804+ if ( / \b _ u p g r a d e _ \b / . test ( brew ) ) {
1805+ if ( needUpdate ) { execSync ( 'brew update' ) }
17881806 brew = brew . replace ( / \b _ u p g r a d e _ \b / gi, '' ) . trim ( )
17891807 }
1790-
1791- if ( brew !== '' ) {
1792- execSync ( `brew install ${ brew } ` )
1793- }
1808+
1809+ if ( brew !== '' ) { execSync ( `brew install ${ brew } ` ) }
17941810 }
17951811 } catch ( error ) {
17961812 core . setFailed ( error . message )
0 commit comments